What is the file structure of the MySQL database? For the Database Command created in this way:
The default database storage location contains a folder named mysqldb. To operate the database, you must stop the database process first:
$sudo /etc/init.d/mysql stop |
The following command transfers the original database to the new location by taking the location of/home/mysql as an example:
$sudo cp –R –p /var/lib/mysql /home/mysql |
Edit the MySQL configuration file:
$gksu gedit /etc/mysql/my.cnf |
Find the datadir line in gedit, change the content after the equal sign to/home/mysql, and save and exit. Since Ubuntu 7.10,
Ubuntu begins to use a security software called AppArmor, which creates a region in your file system that allows application access. Terminology: Application access control ). If you do not modify the AppArmor configuration file for MySQL, you will never be able to start the new database storage location.
Database Service. Configure AppArmor:
$sudo nano /etc/apparmor.d/usr.sbin.mysqld |
Find/var/lib/mysql/In gedit, comment out the two lines, and add a symbol "#" before the two lines to comment out, before the two rows, or
Add the following content:
/home/mysql/ r, /home/mysql/** rwk, |
Save and exit. Run the following command:
$sudo /etc/init.d/apparmor reload |
Return Reloading AppArmor profiles: done. You can restart the MySQL service:
$sudo /etc/init.d/mysql start |
Now the storage location of the MySQL database has been changed.
FAQ:
Q: When I run $ sudo/etc/init. d/apparmor reload, information is returned.
Skipping profile /etc/apparmor.d/usr.sbin.mysqld~ : Warning. |
MySQL service cannot be started. What should I do?
A: This problem may occur because you used commands like $ sudo gedit or $ gksu gedit to edit usr. sbin. for the configuration file mysqld, the two graphic interface text editors will generate a usr at the same location. sbin. mysqld ~ This affects AppArmor's reading of the configuration file. If this problem occurs, delete usr. sbin. mysqld ~ File:
$ Sudo rm/etc/apparmor. d/usr. sbin. mysqld ~
Then, use the terminal text editor $ sudo nano to edit the configuration file.
- Difference between ms SQL Server and MySQL
- How to break through 4G restrictions in a single MySQL table
- Comparison between datetime and timestamp in MySQL