Today to modify the Ubuntu under the MySQL 5.7 Data directory, found no matter how to toss files
/etc/mysql/my.cnf
After the restart is not valid, in the online view of the relevant documents, said to modify the AppArmor file, to organize the document, the steps to write the following.
Version information for the system:
[Email protected] Virtual-machine:~$ uname-a Linux DC-virtual4.10. 0--generic #16.04. 1 - x86_64:x86_64 x86_64 gnu/linux
1. Create a new database directory and modify the owning and owning group
2. Modify the configuration file/etc/my.cnf, if can not find/etc/mysql/my.cnf, if not found, sorry to find a relay it;
Modify DataDir to the directory defined in 1:
DataDir =/var/mysql_data
3. This step is important to modify the relevant configuration file for AppArmor
or modify the file
sudo vim/etc/apparmor/usr.bin.mysqld
may also be under the other path, pay attention to carefully find, this file I also later know, in CentOS, there is no such step.
In the above file:
dir Access /var/lib/MySQL R, /var/lib/mysql*/* RWK,
Note: The/var/lib/mysql/directory above is the default after MySQL is installed.
Modified to:
dir Access /var/mysql_data/ R, /var/mysql_data*/* RWK,
4. Restart the AppArmor service after the modification is complete
Sudo/etc/init.d/apparmor Restart
5. Restart the MySQL service
sudo service MySQL restart
6. Verify that the MySQL directory has changed
Go to the MySQL command line and execute:
Show variables like '%datadir% '
Can.
Ubuntu Mysql 5.7 datadir Data Catalog modification