7. Change the MySQL directory
The default data file storage directory of MySQL is/var/lib/mysql. To move the directory to/home/data, perform the following steps:
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/rc. d/init. d/mysql
Finally, you need to modify the MySQL STARTUP script/etc/rc. d/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/rc. d/init. d/mysql
# Datadir =/var/lib/mysql (comment this row)
Datadir =/home/data/mysql (add this row)
7. Restart the MySQL service.
/Etc/rc. d/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.
VIII. Common MySQL operations
Note: Each Command in MySQL must end with a semicolon.
1. display the database
Mysql> show databases;
+ ---------- +
| Database |
+ ---------- +
| Mysql | this article from the help house: http://www.bkjia.com
| Test |
+ ---------- +
[Content navigation] |
Page 1st: how to install and configure mysql in linux (2) |
Page 2nd: how to install and configure mysql in linux (2) |