How to change the MySQL database directory location under CentOS system 1. First we need to shut down MySQL. The command is as follows: service mysqld stop 2. Then transfer the data. For safety reasons, we use the copy command cp to find the original directory of mysql first. cd /var/lib ls After running this command, you will see the mysql directory, and then execute the cp command cp -a mysql /home/mysql_data/ This will copy the database to Note: (The If the database is large, it will take a long time and may time out. Please find relevant information on how to set ssh to not time out. 3. Then we modify the configuration files. There are three in total. Let me explain them one by one: Modify the first file: Back up before modifying cp /etc/my.cnf /etc/my.cnfbak vi /etc/my.cnf After opening, change the directory of datadir to Change Modify the second file: Back up before modifying cp /etc/init.d/mysqld /etc/init.d/mysqldbak vi /etc/init.d/mysqld Note: The exact location is So just use the above command, it is also simple. In the line Modify the third file: Back up before modifying cp /usr/bin/mysqld_safe /usr/bin/mysqld_safebak vi /usr/bin/mysqld_safe Here we also modify the 4. Next, you need to create a ln -s /home/mysql_data/mysql/mysql.sock /var/lib/mysql/mysql.sock At this point all modifications are complete, start mysql service mysqld start Or restart linux reboot Check if Mysql is running normally. If it can start normally, there is basically no problem. For more basic tutorials on MySQL, please click on the following related articles You may also be interested in:
|
<<: Use nginx + secondary domain name + https support
>>: Summary of several common ways to abbreviate javascript code
How to display text overflow? What are your needs...
Table of contents 1. Install Docker 2. Pull the J...
Table of contents Preface The difference between ...
Log in docker login Complete the registration and...
When insert into employee values(null,'張三'...
In the previous chapters, we have learned how to ...
The event scheduler in MySQL, EVENT, is also call...
Table of contents 1. Steps to use Jquery: (1) Imp...
Table of contents 1. DateTimePicker date selectio...
Introduce two methods to view MySQL user permissi...
Table of contents Scenario Analysis Development S...
1. Use of CSS scope (style division) In Vue, make...
Table of contents Preface Descriptors Detailed ex...
Table of contents Preface 1. How to write functio...
There are many reasons why an application is as s...