CentOS mysql Modify database directory _mysql

Source: Internet
Author: User
Tags socket

MySQL default data file storage directory/var/lib/mysql, now to modify the directory to/home/data/mysql
Cd/home
mkdir data//In the home directory to build the data directory
Mysqladmin-u root-p shutdown//stop MySQL service process:
mv/var/lib/mysql/home/data///Mobile Directory
CP/ETC/MY.CNF/ETC/MY.CNF//Find MY.CNF configuration file in/etc/directory

[If not found, you can find *.cnf files under/usr/share/mysql/, copy one to/etc/and renamed MY.CNF,
Cp/usr/share/mysql/my-medium.cnf/etc/my.cnf
]
Edit MySQL's profile/etc/my.cnf to work properly for MySQL, indicating where the Mysql.sock file will be generated,
Modify
Socket=/var/lib/mysql/mysql.sock
Become:
Socket=/home/mysql/mysql.sock

Operation Process
VI my.cnf
# The MySQL server
[Mysqld]
Port = 3306
#socket =/var/lib/mysql/mysql.sock//original content, in order to safely use the "#" annotation line, plus the following
Socket =/home/data/mysql/mysql.sock

Modify the MySQL startup script/etc/rc.d/init.d/mysql
Modify
Datadir=/var/lib/mysql
Modified into:
Datadir=home/data/mysql

Restart the MySQL service
/etc/rc.d/init.d/mysql start
or reboot command to reboot Linux

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.