In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
A few days ago, I found that because the database of MySQL is too large, the default installed / vardisk can no longer hold the newly added data, so I can only find a way to transfer the directory of the data. There are many related articles written on the Internet to transfer the database directory, but there will be some errors in the process of reprinting, because most people have not tested it at all. This article is tested and sorted out and shared with you.
The purpose of this article is to briefly sort out the specific operations of transferring MySQL from the / var/lib/mysql directory to / home/mysql_data/mysql these days.
First, we need to shut down MySQL with the following command:
# service mysqld stop
There are a lot of people on the Internet are using mysqladmin-u root-p shutdown, but my system is installed is a kloxo panel, root password does not know, although it can be reset, but more troublesome.
Then the data is transferred. For security purposes, we use the replicated command cp to find the original directory of mysql first.
# cd / var/lib#ls
After running this command, you will see the directory of mysql, and then execute the cp command
# cp-a mysql / home/mysql_data/
In this way, the database is copied under / home/mysql_data. Note that the parameter-a must be taken with it, otherwise the permissions copied in the past will be incorrect. If the database is large, it will take a long time and may time out.
Then we modify the configuration file, there are a total of three, I will explain one by one below:
# vi / etc/my.cnf
After opening it, change the datadir directory to / home/mysql_data/mysql and change socket to / home/mysql_data/mysql/mysql.sock. For security reasons, you can delete the original comment, then add a new line and change it to the current directory.
# vi / etc/init.d/mysqld
The exact location is / etc/rc.d/init.d/mysqld, and since there is a mapping from / etc/init.d to / etc/rc.d/init.d here, it's easy to use the command above.
Here, the main thing is to change the directory of datadir to / home/mysql_data/mysql
# vi / usr/bin/mysqld_safe
This is also the directory where datadir is modified.
The following needs to establish a link to mysql.sock:
# ln-s / home/mysql_data/mysql/mysql.sock / var/lib/mysql/mysql.sock
Now that all the changes have been completed, start mysql
# service mysqld start
Or restart Linux
# reboot
Summary
The above is the whole content of this article, I hope that the content of this article can bring some help to your study or work, if you have any questions, you can leave a message and exchange.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.