How Linux MySQL moves the MySQL database directory location

Source: Internet
Author: User

 
If you want to move the directory to/home/data under the following steps: 1, the home directory to establish the data directory cd/home mkdir data 2, the MySQL service process is stopped: mysqladmin-u root-p shutdown 3, Move/var/lib/mysql Entire directory to/home/data mv/var/lib/mysql/home/data/This will move the MySQL data file to/home/data/mysql 4, find the MY.CNF configuration file if/ etc/directory does not have a my.cnf configuration file, please find the *.cnf file under/usr/share/mysql/, copy one of them to/etc/and rename it to MY.CNF). The command is as follows: [[[Email protected] mysql]# cp/usr/share/mysql/my-medium.cnf/etc/my.cnf 5, edit the configuration file for MySQL/etc/my.cnf to ensure mysq L can work properly and need to indicate where the Mysql.sock file is generated. Modify the value in the Socket=/var/lib/mysql/mysql.sock line to the right of the equals sign:/home/mysql/mysql.sock. Operation is as follows: VI my.cnf (edit my.cnf file with VI tool, find the following data to modify) # The MySQL server [mysqld] Port = 3306 #socket =/var/lib/ Mysql/mysql.sock (original content, in order to be more secure with "#" comment this line) socket =/home/data/mysql/mysql.sock (plus this line) 6, modify the MySQL startup script/etc/init.d/mysql Finally,  The MySQL startup script needs to be modified/etc/init.d/mysql, and the path to the right of the equal sign in the Datadir=/var/lib/mysql line is changed to your current actual storage path: Home/data/mysql. [[email protected] etc]# vi/etc/init.d/mysql #datadir =/var/lib/mysql (note this line) Datadir=/home/data/mysql (plus this line) 7. Restart the MySQL service/etc/init.d/mysql start or restart Linux with the reboot command if the work moves successfully, otherwise check the previous 7 steps. Also pay attention to the owner and permission of the directory.

How Linux MySQL moves the MySQL database directory location

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.