Change Mysql Data Directory in Debian 7?

I have a separate section that contains both my www and mysql folders.

I have a set of partitions for auto-mount on boot, and apache2 starts normally, no errors.

However, when I just deleted all traces of mysql-server-5.5, rebooted and restarted it, it will work fine.

But second, I make changes to my.cnf to point to / media / server / mysql and try to start mysql, after which it will fail.

Here is a list of the steps that I have completed so far. Keep in mind that Debian has no reach as far as I know, so I skipped this step.

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.

from How to change the MySQL data directory?

Although I also looked at the link here https://askubuntu.com/questions/137424/moving-mysql-datadir

, , .

root@debian:~# chown -R mysql:mysql /media/server/mysql
root@debian:~# sudo /etc/init.d/mysql restart
[ ok ] Stopping MySQL database server: mysqld.
[FAIL] Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!

, Linux, -, , , .

, .

, , , dir , mysql .

webdev.

, .

+4
2

datadir (/var/lib/mysql) . .

:

sudo cp -R -p /var/lib/mysql /newpath

:

sudo mv /var/lib/mysql /newpath

datadir, , :

sudo cp -R -p /var/lib/mysql /var/lib/mysql.bak
sudo mv /var/lib/mysql /newpath

mysql, :)

!

+5

, . , mysql deamon - .

, "mysql-bin.index" bin .

mysql - .

0

Source: https://habr.com/ru/post/1530893/


All Articles