Centos: Modify the yum installed MySQL path

Source: Internet
Author: User

1.
Use the command service mysqld stop to stop MySQL
To view the default path for the MySQL database:/var/lib/mysql
Using cp-afir/var/lib/mysql/*/usr/local/mysql
Here's a f i r parameter specifically what to refer to the help of the CP
2.
Change MY.CNF
Use command: VIM/ETC/MY.CNF
Change the DataDir to a new path
Datadir=/usr/local/mysql
To ensure that MySQL is normal, you need to indicate where the Mysql.sock file is generated.
#socket =/var/lib/mysql/mysql.sock (original content, in order to be more secure with "#" Comment this line)
Socket =/usr/local/mysql/mysql.sock (plus this line)
3, modify the MySQL startup script/etc/init.d/mysqld,
Change the Datadir=/var/lib/mysql line to your current actual storage path/usr/local/mysql
[Email protected] etc]# Vi/etc/init.d/mysqld
#datadir =/var/lib/mysql (Note this line)
Datadir=/usr/local/mysql (plus this line)
4.
Modify Etc/php.ini Add Mysql.default_socket path
Mysql.default_socket =/usr/local/mysql/mysql.sock
5, Ln-s/usr/local/mysql/mysql.sock/var/lib/mysql/mysql.sock
Create a soft link for mysql.sock, otherwise you will be prompted not to find/var/lib/mysql/mysql.sock
6. Restart Mysqld
Service mysqld Restart

Reproduced

Centos: Modify the yum installed MySQL path

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.