Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of modifying mysql installation path

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the method of modifying the installation path of mysql, which is very detailed and has certain reference value. Friends who are interested must finish it!

The method to modify the installation path of mysql is as follows: first, use the command to stop mysql, establish the target storage directory and use the command to copy files; then modify the MySQL configuration file; then modify the MySQL startup script; finally restart mysqld service mysqld restart.

How to modify the installation path of mysql:

1. Use the command: service mysqld stop to stop mysql, check the default path of the mysql database: / var/lib/mysql, establish the target storage directory: mkdir / home/data, and 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 the MySQL can be normal, you can not modify the location of the mysql.sock file, or indicate the location of the new mysql.sock file.

Socket = / var/lib/mysql/mysql.sock (original content, you can comment this line with "#", or this line can not be changed)

Socket = / home/data/mysql/mysql.sock (plus this line)

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

4. If you modify the location where mysql.sock is generated in the MySQL configuration file / etc/my.cnf, you need to make a link to the new file location. The command above ln-sv / home/data/mysql/mysql.sock / var/lib/mysql/mysql.sock establishes a soft link for mysql.sock, otherwise the file / var/lib/mysql/mysql.sock will not be found when logging in using the mysql client

5. Restart mysqld service mysqld restart

The above is all the contents of the method to modify the mysql installation path, thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report