09/03
10
How to move the mysql data directory in ubuntu
* Open the terminal
* Stop MySQL with the command
* Copy the existing data directory (which is located in /var/lib/mysql) using the command
* All you need are the data files. Delete the others with the command
(You will get a message about not being able to delete some directories, but do not care about them)
* Edit the MySQL configuration file with the command
* Find the entry for datadir, change the path to the new data directory.
* But there is a trick involved here. Ubuntu uses some security software called AppArmor that specifies the areas of your filesystem applications are allowed to access. Unless you modify the AppArmor profile for MySQL, you'll never be able to restart MySQL with the new datadir location.
* In the terminal, enter the command
* Copy the lines beginning with /var/lib/mysql
* Comment out the originals with hash marks (#), and paste the lines below the originals.
* Now change /var/lib/mysql in the two new lines with /usr/new_datadir. Save and close the file.
* Restart the AppArmor profiles with the command
* Restart MySQL with the command
* MySQL should now start without any errors and your data will be stored in the new location. See also article Linux Ubuntu move mysql database to other path in 5 minutes
* Stop MySQL with the command
/etc/init.d/mysql stop
* Copy the existing data directory (which is located in /var/lib/mysql) using the command
cp -R -p /var/lib/mysql /usr/new_datadir
* All you need are the data files. Delete the others with the command
rm /usr/new_datadir
(You will get a message about not being able to delete some directories, but do not care about them)
* Edit the MySQL configuration file with the command
vim /etc/mysql/my.cnf
* Find the entry for datadir, change the path to the new data directory.
* But there is a trick involved here. Ubuntu uses some security software called AppArmor that specifies the areas of your filesystem applications are allowed to access. Unless you modify the AppArmor profile for MySQL, you'll never be able to restart MySQL with the new datadir location.
* In the terminal, enter the command
vim /etc/apparmor.d/usr.sbin.mysqld
* Copy the lines beginning with /var/lib/mysql
* Comment out the originals with hash marks (#), and paste the lines below the originals.
* Now change /var/lib/mysql in the two new lines with /usr/new_datadir. Save and close the file.
* Restart the AppArmor profiles with the command
/etc/init.d/apparmor restart
* Restart MySQL with the command
/etc/init.d/mysql restart
* MySQL should now start without any errors and your data will be stored in the new location. See also article Linux Ubuntu move mysql database to other path in 5 minutes
MySQL 命令方式常用操作指令
Tokyo Tyrant 启动命令


