Home > Database > Mysql Tutorial > body text

How to modify the installation path of mysql

coldplay.xixi
Release: 2020-10-19 15:04:49
Original
5953 people have browsed it

How to modify the installation path of mysql: first use the command to stop mysql, create the target storage directory and use the command to copy the file; then modify the MySQL configuration file; then modify the MySQL startup script; finally restart the mysqld service mysqld restart. Can.

How to modify the installation path of mysql

How to modify the installation path of mysql:

1. Use the command: service mysqld stop to stop mysql and view The default path of mysql database: /var/lib/mysql, create the target storage directory: mkdir /home/data, use the command to copy the file: cp -R /var/lib/mysql /home/data/mysql

2. Modify the MySQL configuration file: /etc/my.cnf. Use VIM to edit: vim /etc/my.cnf. Change the datadir to the new path datadir=/home/data/mysql. To ensure that MySQL can function normally, it does not need to be modified. The location of the mysql.sock file, or specify the location where the new mysql.sock file is generated.

socket =/var/lib/mysql/mysql.sock (the original content, you can use "#" to comment this line, this line can also be left unchanged)

socket =/home/ data/mysql/mysql.sock (Add this line)

3. Modify the MySQL startup script /etc/init.d/mysqld and find getmysqloption mysqld datadir "/var/lib/mysql/mysql" double quotes Change the content in to the actual storage path /home/data/mysql

4. If you modify the generation location of mysql.sock in the MySQL configuration file /etc/my.cnf, you need to make a link to point to New file location. ln -sv /home/data/mysql/mysql.sock /var/lib/mysql/mysql.sock The above command creates a soft link to mysql.sock, otherwise when you log in using the mysql client, you will be prompted that the file cannot be found/ var/lib/mysql/mysql.sock

5. Restart mysqld service mysqld restart

More related free learning recommendations: mysql tutorial(Video)

The above is the detailed content of How to modify the installation path of mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!