mysql修改数据文件路径

  1. 再Ubuntu环境下,修改datadir后,重启不成功,按照以下的方法,终于ok

http://www.thinksaas.cn/group/topic/347966/

  1. Stop MySQL using the following command: sudo /etc/init.d/mysql stop
  2. Copy the existing data directory (default located in /var/lib/mysql) using the following command:sudo cp -R -p /var/lib/mysql /newpath
  3. edit the MySQL configuration file with the following command:gedit /etc/mysql/my.cnf
  4. Look for the entry for datadir, and change the path (which should be /var/lib/mysql) to the new data directory.
  5. In the terminal, enter the command:sudo gedit /etc/apparmor.d/usr.sbin.mysqld
  6. Look for lines beginning with /var/lib/mysql. Change /var/lib/mysql in the lines with the new path.
  7. Save and close the file.
  8. Restart the AppArmor profiles with the command:sudo /etc/init.d/apparmor reload
  9. Restart MySQL with the command:sudo /etc/init.d/mysql restart
  10. Now login to MySQL, and you can access the same databases you had before.

猜你喜欢

转载自cavenfeng.iteye.com/blog/2262169