1.
Use the command service mysqld stop to stop MySQL
To view the default path for the MySQL database:/var/lib/mysql
Using cp-afir/var/lib/mysql/*/usr/local/mysql
Here's a f i r parameter specifically what to refer to the help of the CP
2.
Change MY.CNF
Use command: VIM/ETC/MY.CNF
Change the DataDir to a new path
Datadir=/usr/local/mysql
To ensure that MySQL is normal, you need to indicate where the Mysql.sock file is generated.
#socket =/var/lib/mysql/mysql.sock (original content, in order to be more secure with "#" Comment this line)
Socket =/usr/local/mysql/mysql.sock (plus this line)
3, modify the MySQL startup script/etc/init.d/mysqld,
Change the Datadir=/var/lib/mysql line to your current actual storage path/usr/local/mysql
[Email protected] etc]# Vi/etc/init.d/mysqld
#datadir =/var/lib/mysql (Note this line)
Datadir=/usr/local/mysql (plus this line)
4.
Modify Etc/php.ini Add Mysql.default_socket path
Mysql.default_socket =/usr/local/mysql/mysql.sock
5, Ln-s/usr/local/mysql/mysql.sock/var/lib/mysql/mysql.sock
Create a soft link for mysql.sock, otherwise you will be prompted not to find/var/lib/mysql/mysql.sock
6. Restart Mysqld
Service mysqld Restart
Reproduced
Centos: Modify the yum installed MySQL path