I am using mysql 5.6. I wanted to change the data directory for my database. So did following steps -
1. copy whole mysql folder from /var/lib/mysql/ to new folder named app.
2. Then grant permission to that folder.
3. stop mysql server.
4. changes in my.cnf for datadir =/app/mysql and socket variable = /app/mysql/mysql.sock
5. restart the server.
Now when I am trying to run mysql -uroot -proot it gives me following error -
'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
But when I can log in using following -
mysql -uroot -proot -h 127.0.0.1 or my system's IP or --socket = /app/mysql/mysql.sock
Please let me know what I have missed.
EDIT: When I am commenting socket variable in my.cnf. It is accessing mysql.sock from old path but working fine.
# socket = /app/mysql/mysql.sock
Is it correct to use it or I have to use from same data dir?