- Stop MySQL using the following command:
sudo /etc/init.d/mysql stop
- Copy the existing data directory (default located in /var/lib/mysql) using the following command:
sudo cp -R -p /var/lib/mysql /newpath
- edit the MySQL configuration file with the following command:
gedit /etc/mysql/my.cnf
- Look for the entry for datadir, and change the path (which should be /var/lib/mysql) to the new data directory.
- In the terminal, enter the command:
sudo gedit /etc/apparmor.d/usr.sbin.mysqld
- Look for lines beginning with /var/lib/mysql. Change /var/lib/mysql in the lines with the new path.
- Save and close the file.
- Restart the AppArmor profiles with the command:
sudo /etc/init.d/apparmor reload
- Restart MySQL with the command:
sudo /etc/init.d/mysql restart
- Now login to MySQL, and you can access the same databases you had before.
Change mysql datadir (for Ubuntu)
原文作者:dreambei
原文地址: https://segmentfault.com/a/1190000000533997
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
原文地址: https://segmentfault.com/a/1190000000533997
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。