1

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...

2
  • ps -ef | grep mysql?
    – quanta
    Jul 5, 2012 at 6:37
  • 1
    Does MySQL has permissions to access /data/mysql?
    – Wasif
    Jul 6, 2012 at 11:52

2 Answers 2

1

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/

0

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).

1
  • 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, 2012 at 18:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .