Linux MySQL Data Directory folder move and problems encountered
Source: Internet
Author: User
<span id="Label3"> </p><p>first, if the fedora under the RPM package installed mysql, The modified method is as Follows: if this is not clear enough, you can go to http://www.vipkj.net/post-839.html to give me a message mysql default data file storage directory Is/var/lib /mysql. 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 sh Utdown 3,/var/lib/mysql The entire directory to/home/data mv/var/lib/mysql/home/data/so that the MySQL data files moved to The/home/data/mysql 4, to find To the MY.CNF profile if The/etc/directory does not have a my.cnf profile, locate the *.cnf file under/usr/share/mysql/, and 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 M Ysql 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 =/va R/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/rc.d/ini T.d/mysql finally, You need to modify the MySQL startup script/etc/rc.d/init.d/mysql, which datadir=/var/lib/mysqlline, the path to the right of the equal sign is changed to your current actual storage path: Home/data/mysql. [[email protected] etc]# vi/etc/rc.d/init.d/mysql #datadir =/var/lib/mysql (note this line) datadir=/home/data/mysql (plus this line) 7. Restart the MySQL service/etc/rc.d/init.d/mysql start or restart Linux with the reboot command</p><p><p>The following is a MySQL Data Directory modification error 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ' (2) wrong Solution: This example is to move the MySQL data directory to the/home/data/, that is, Mysql.sock is located in the real directory For,/home/data/mysql/mysql.sock ERROR 2002 (HY000): Can ' t Connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ' (2) MySQL has TCP connection and socket connection mode, The above error is generally because MySQL is installed using the RPM method, it will automatically find/var/lib/mysql/mysql.sock this file, is a socket connection Method. Common solutions are as Follows: 1. create/modify file/etc/my.cnf file, add [client] #password =your_password port=3306 socket=/home/data/mysql/on [mysqld] Mysql.sock #在这里写上你的mysql. Sock in the right place. 2, Specify the IP address, the use of TCP connection to mysql, instead of using the local socket method #mysql-h127.0.0.1-uuser-ppassword 3, Add a connection for mysql.sock, such as the actual Mysql.sock in/ home/data/mysql/, the #ln-s/home/data/mysql/mysql.sock/var/lib/mysql/mysql.sock can</p></p><p><p></p></p><p><p>If it is under the Unbuntu system, *********************** shut down the database services service MySQL stop jianxin database directory mkdir/ media/hda11/db copy Linux under the original data to the new directory cp-pr/var/lib/mysql/media/hda11/db/modify the File/etc/apparmor.d/usr.sbin.mysqld gedit/etc/ Apparmor.d/usr.sbin.mysqld/var/lib/mysql r,/var/lib/mysql/** rwk, Change To/media/hda11/db/mysql r,/media/hda11/db/mysql /** rwk, Modify the directory gedit/etc/mysql/my.cnf such as DataDir =/var/lib/mysql switch to DataDir =/media/hda11/db/mysql and then open the Server/etc/init.d/apparm Or restart Servcie MySQL star</p></p><p><p>Linux MySQL Data Directory folder move and problems encountered</p></p></span>
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