After modifying the storage path of the mysql database, you can't start it until you have forgotten it. Later, you can view it in ls-Z. It turns out to be selinux. You can use chcon-t mysqld_db_t/home/mysqlData.
The method for changing the database location is attached:
1. Create a data directory under the home Directory
Cd/home
Mkdir data
2. Stop the MySQL service process:
Mysqladmin-u root-p shutdown
3. Move the entire/var/lib/mysql directory to/home/data
Mv/var/lib/mysql/home/data/
In this way, the MySQL data file is moved to/home/data/mysql.
4. Find the my. cnf configuration file.
If my. for the cnf configuration file, go to/usr/share/mysql/and find *. copy one of the cnf files to/etc/and change it to my. cnf. The command is as follows:
[Root @ test1 mysql] # cp/usr/share/mysql/my-medium.cnf/etc/my. cnf
5. Edit the MySQL configuration file/etc/my. cnf.
To ensure that MySQL works properly, you must specify the location where the mysql. sock file is generated. Change socket =/var/lib/mysql. sock to/home/mysql. sock. The procedure is as follows:
Vi my. cnf (use the vi tool to edit the my. cnf file and find the following data to modify)
# The MySQL server
[Mysqld]
Port = 3306
# Socket =/var/lib/mysql. sock)
Socket =/home/data/mysql. sock (add this line)
6. Modify the MySQL STARTUP script/etc/init. d/mysql
Finally, you need to modify the MySQL STARTUP script/etc/init. d/mysql: change the path on the Right of datadir =/var/lib/mysql to your actual storage path: home/data/mysql.
[Root @ test1 etc] # vi/etc/init. d/mysql
# Datadir =/var/lib/mysql (comment this row)
Datadir =/home/data/mysql (add this row)
7. Restart the MySQL service.
/Etc/init. d/mysql start
Or use the reboot command to restart Linux.
If it works properly, it will succeed. Otherwise, check again against the previous seven steps.
Pay attention to the owner and permissions of the directory.