In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Preface
The company's Ubuntu server is placed on different logical partitions for the directories of each system, such as the default directory for storing mysql database files / the system directory where var/lib/mysql is located / var/ is on a separate partition, but the size of this partition is fixed and not enough to store the entire database file. But another system directory / data is T-sized, which greatly meets the requirements, so there is a need to change the database file directory.
Here's how I tried with reference to some articles on the Internet:
1. Stop the database service:
Use / etc/init.d/mysql stop or stop mysql
two。 Create a directory of database files (such as / mysqldb) at the target location (/ data), and copy (if you no longer use the default location, you can directly mv the original database files to the new directory) and copy the original database files directory to this directory:
Cd / datamkdir mysqldbcp-r / var/lib/mysql / data/mysqldb/
After a period of waiting, there is a copy of the original default mysql database file directory "/ mysql" under / data/mysqldb/.
3. Modify the my.cnf file
# vim / etc/mysql/my.cnf
Change datadir = / var/lib/mysql to datadir = / data/mysqldb/mysql
In addition, since socket = / var/run/mysqld/mysqld.sock in the current my.cnf (instead of sock = / var/lib/mysql/mysql.sock as mentioned on the Internet), that is, the location of the socket is not in the same location as the database file, it is possible not to do what other web pages say, but to make a mysql.sock link using the following command:
Ln-s / data/mysqldb/mysql/mysql.sock / var/lib/mysql/mysql.sock (need to make a copy from / home/data/mysql)
4. Modify the permissions of the database:
# chown-R mysql:mysql / data/mysqldb/mysql/ ← change the attribute of the database file directory to mysql# chmod 700 / data/mysqldb/mysql/whois/ ← change the attribute of the database directory whois to 70 chmod / data/mysqldb/mysql/whois/* ← change the attribute of the data table in the database to 660
5. Modify the file usr.sbin.mysqld
# vim / etc/apparmor.d/usr.sbin.mysqld
Put
/ var/lib/mysql r _ max _ varql _ max _ MySQL _ rwk
Change to
/ data/mysqldb/mysql/ r _ rwk _
Note: without this step, the database service will not be able to restart, as if it is restarting, but it has been stuck and unresponsive.
6. Start the mysql server
/ etc/init.d/apparmor restart/etc/init.d/mysql restart (or use restart mysql)
Got it!
Summary
The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.
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.