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
I encountered a case at work that I had never wri...
A few days ago, a colleague asked me a question a...
These introduced HTML tags do not necessarily ful...
1. About Registry The official Docker hub is a go...
1: Introduction to syslog.conf For different type...
This article summarizes the principles and usage ...
1. Dashed box when cancel button is pressed <br...
Simple example of HTML checkbox and radio style b...
Today when I was writing a flash advertising code,...
This article lists some tips and codes about form...
Because I need to install MySQL, I record the ins...
Table of contents 1. What is reflection? 2. Refle...
What is the purpose of this sentence? Copy code Th...
Preface gdb is a very useful debugging tool under...
1. Problem During development, when inserting dat...