Preface The company's Ubuntu server places the directories of various systems on different logical partitions. For example, the default directory /var/lib/mysql for storing MySQL database files is located in a separate partition, and the system directory /var/ is located in a separate partition. However, the size of this partition is fixed and is not enough to store the entire database file. However, the size of another system directory /data reaches T level, which greatly meets the needs, so there is a need to change the database file directory. The following is the process I tried by referring to some articles on the Internet: 1. Stop the database service: Use 2. Create a directory for the database file (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 file to the new directory) the original database file directory to this directory: cd /data mkdir mysqldb cp -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 In addition, since the current my.cnf has ln -s /data/mysqldb/mysql/mysql.sock /var/lib/mysql/mysql.sock (need to copy a copy from /home/data/mysql) 4. Modify the database permissions: # chown -R mysql:mysql /data/mysqldb/mysql/ ← Change the ownership of the database file directory to mysql # chmod 700 /data/mysqldb/mysql/whois/ ← Change the whois attribute of the database directory to 700 # chmod 660 /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 Bundle /var/lib/mysql r, /var/lib/mysql/** rwk, Change to /data/mysqldb/mysql/ r, /data/mysqldb/mysql/** rwk, Note: Without this step, the database service will not be able to restart. It seems to be restarting, but it is stuck and unresponsive. 6. Start mysql server /etc/init.d/apparmor restart /etc/init.d/mysql restart (or use restart mysql) Done! Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM. You may also be interested in:
|
<<: How to install MySQL and MariaDB in Docker
>>: Vue+spring boot realizes the verification code function
background I originally wanted to download a 6.7 ...
Table of contents 1. Object literals 2. The new k...
How to make tomcat support https access step: (1)...
Table of contents Tomcat Download Tutorial Tomcat...
Here is the mysql driver mysql.data.dll Notice: T...
If we want to perform batch operations on a type ...
In new projects, axios can prevent duplicate subm...
1. Official website address The official website ...
Preface Excel is powerful and widely used. With t...
border-radius:10px; /* All corners are rounded wi...
Table of contents Preface text 1. Panel 2. Huaron...
Preface Today I encountered a very strange proble...
System environment: centos7.4 1. Check whether th...
This article uses examples to describe how to bac...
Preface Dockerfile is a script interpreted by the...