I have a server hosted on Scaleway with multiple staging sites on.
I accidentally archived the server instead of turning it off which means the MySQL data for my websites is currently stored in /mnt/volume0/var/lib/mysql
however MySQL is currently looking at /var/lib/mysql
therefore none of my databases are being picked up.
How can I get MySQL to look at the path to the MySQL data on the volume instead?
I have tried following this guide: https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04
However when it comes to starting MySQL up again, I get:
Job for mysql.service failed because the control process exited with
error code. See "systemctl status mysql.service" and "journalctl -xe"
for details.
And running systemctl status mysql
gives:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Wed 2017-06-28 17:53:13 UTC; 2s ago
Process: 16742 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 16734 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 16742 (code=exited, status=1/FAILURE); : 16743 (mysql-systemd-s)
CGroup: /system.slice/mysql.service
└─control
├─16743 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─16751 sleep 1
I would try moving the contents of /mnt/volume0/var/lib/mysql
to /var/lib/mysql
however as far as I understand, if I did I would run out of space on the server
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 1010M 0 1010M 0% /dev
tmpfs 203M 29M 175M 14% /run
none 1012M 845M 168M 84% /
tmpfs 1012M 0 1012M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 1012M 0 1012M 0% /sys/fs/cgroup
/dev/nbd0 46G 46G 0 100% /mnt/volume0
/dev/nbd1 92G 41G 47G 47% /mnt/volume
Thanks!
Если вам нужно временное решение:
mount -o bind /mnt/volume0/var/lib/mysql /var/lib/mysql
Или в MySQL, в /etc/my.cnf вам нужно изменить datadir , чтобы указать на новую папку. Например. datadir = / mnt / volume0 / var / lib / mysql
. Убедитесь, что / mnt / volume0 / var / lib / mysql доступен для записи.
Я решил эту проблему, заменив содержимое / var / lib / mysql /
на моем локальном компьютере содержимым / mnt / volume0 / var / lib / mysql /
(с сервера).
Затем я обнаружил ошибку при попытке запустить MySQL Таблица «performance_schema.session_variables» не существует, которую я решил, обновив MySQL на моем локальном компьютере и перезапустив: https://stackoverflow.com/a/20262826/8231049[1220 visible Теперь я могу выгружать базы данных с моей локальной машины :)
Изменить: не могу принять свой ответ, пока не подождал 2 дня. Тогда подойдет.