Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've changed data directory in /etc/my.cnf.

datadir=/data/mysql
socket=/data/mysql/mysql.sock

I also moved mysql folder from

/var/lib/mysql/ 

to

/data/mysql

Now when i connect to mysql i get following error:

[root@youradstats-copy mysql]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

also when i see /var/logs/msqld.log i get following messages in that:

InnoDB: Setting log file /data/mysql/ib_logfile0 size to 512 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100 200 300 400 500
120704  7:43:31  InnoDB: Log file /data/mysql/ib_logfile1 did not exist: new to be created
InnoDB: Setting log file /data/mysql/ib_logfile1 size to 512 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100 200 300 400 500
InnoDB: Cannot initialize created log files because
InnoDB: data files are corrupt, or new data files were
InnoDB: created when the database was started previous
InnoDB: time but the database was not shut down
InnoDB: normally after that.
120704  7:43:36 [ERROR] Plugin 'InnoDB' init function returned error.
120704  7:43:36 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

I shut down mysql properly before doing these changes and then started it properly but dont know why getting these messages. please help to solve issue as i have changed socket path in my.cnf but still its pointing to old path...

share|improve this question
    
ps -ef | grep mysql? –  quanta Jul 5 '12 at 6:37
1  
Does MySQL has permissions to access /data/mysql? –  mwasif Jul 6 '12 at 11:52

2 Answers 2

Check to see if you have the socket file in the new location?

ls -la /data/mysql/mysql.sock

If it exists, are the permissions correct? Show us if you're unsure.

The next step if it exists is to try:

mysql -S /data/mysql/mysql.sock

If that works then you simply need to change the sock=/path/ in the [client] section of your my.cnf file. If that doesn't exist there, then you should create it.

It is not required to restart mysql when you change things in the [client] section of the my.cnf file.

On another note, the log messages you posted makes it looks like you did not copy the data from your /var/lib/mysql/ directory properly, or you have a permissions issue. If you're unsure, show us the output of ls -la /data/mysql/

share|improve this answer

You should have [mysql-client] section in your /etc/my.cnf or /root/.my.cnf file which define where the socket is located.

If you read your MySQL log, it tell you that restarting the database is required (/etc/init.d/mysqld restart).

share|improve this answer
    
i have this section in my.cnf file. also i restarted couple of times mysql after doing these changes but no success yet. –  user123827 Jul 4 '12 at 18:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.