Centos: how to modify the mysql path installed by yum

Source: Internet
Author: User

1,
Use the Command service mysqld stop to stop mysql
View the default path of the mysql database:/var/lib/mysql
Use cp-afir/var/lib/mysql/*/usr/local/mysql
For details about the f I r parameter, see cp help.
2,
Change my. cnf
Run the command vim/etc/my. cnf.
Change datadir to a new path.
Datadir =/usr/local/mysql
To ensure that MySQL works properly, you must specify the location where the mysql. sock file is generated.
# Socket =/var/lib/mysql. sock)
Socket =/usr/local/mysql. sock (add this line)
3. Modify the MySQL STARTUP script/etc/init. d/mysqld,
Change the datadir =/var/lib/mysql line to your actual storage path/usr/local/mysql.
[Root @ test1 etc] # vi/etc/init. d/mysqld
# Datadir =/var/lib/mysql (comment this row)
Datadir =/usr/local/mysql (add this row)
4,
Modify etc/php. ini to add mysql. default_socket path
Mysql. default_socket =/usr/local/mysql. sock
5. ln-s/usr/local/mysql. sock/var/lib/mysql. sock
Create a soft link for mysql. sock. Otherwise, the system will prompt that/var/lib/mysql. sock cannot be found.
6. Restart mysqld.
Service mysqld restart

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.