我使用了https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04上的指南,将MySQL数据目录从默认的/ var / lib / mysql移至/ media / lukas / data2 / mysql
当我尝试使用sudo systemctl start mysql
启动mysql(指南中的第4步)时,出现错误:
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
systemctl状态mysql.service返回:
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Út 2019-12-03 11:51:17 CET; 17s ago
Process: 8869 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 8860 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 8869 (code=exited, status=1/FAILURE); : 8870 (mysql-systemd-s)
CGroup: /system.slice/mysql.service
└─control
├─8870 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─8906 sleep 1
pro 03 11:51:17 PC-Nusle systemd[1]: Starting MySQL Community Server...
pro 03 11:51:17 PC-Nusle mysqld[8869]: mysqld: Can't change dir to '/media/lukas/data2/mysql/' (Errcode: 13 - Permission denied)
pro 03 11:51:17 PC-Nusle mysqld[8869]: 2019-12-03T10:51:17.363881Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
pro 03 11:51:17 PC-Nusle mysqld[8869]: 2019-12-03T10:51:17.363970Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
pro 03 11:51:17 PC-Nusle mysqld[8869]: 2019-12-03T10:51:17.538962Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server o
pro 03 11:51:17 PC-Nusle systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
因此,看来mysql无法使用/ media / lukas / data2 / mysql /文件夹,但该文件夹的所有者是mysql: drwx ------ 11 mysql mysql 4,0K pro 3 10:52 mysql ,所以我不明白这个错误。我试图将/ media / lukas / data2 / mysql /的权限更改为777,但无济于事。