askubuntu.com,我需要一些帮助来调试我的 MySQL 设置!在过去的几年里,我一直在 Dropbox 上托管我的本地开发资源,它运行良好。上周,我决定清理我的计算机并这次使用 Ubuntu 而不是 Linux Mint(无关紧要,但是耶!)。所以,关于重要的细节:
设置
中的 datadir 条目/etc/mysql/mysql.conf.d/mysqld.cnf
定义为datadir = "/home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql"
.
/home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases
777的权限(悲伤的脸,但我现在试图消除可能性)和所有者用户/组是mysql:mysql,递归。
我在/etc/apparmor.d/tunables/alias
as中定义了一个 Apparmor 别名alias /var/lib/mysql/ -> "/home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/",
。我还添加了条目/etc/apparmor.d/usr.sbin.mysqld
作为
# Allow data dir access
/var/lib/mysql/ r,
"/home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/" r,
/var/lib/mysql/** rwk,
"/home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/**" rwk,
此外,在我的测试期间,我使用(如何禁用 AppArmor for MySQL)中的说明从强制执行列表中删除了 MySQL,因此 Apparmor 根本不应该影响进程。我的输出sudo aa-status
是
apparmor module is loaded.
39 profiles are loaded.
39 profiles are in enforce mode.
/snap/core/9289/usr/lib/snapd/snap-confine
/snap/core/9289/usr/lib/snapd/snap-confine//mount-namespace-capture-helper
/snap/snapd/7777/usr/lib/snapd/snap-confine
/snap/snapd/7777/usr/lib/snapd/snap-confine//mount-namespace-capture-helper
/usr/bin/evince
/usr/bin/evince-previewer
/usr/bin/evince-previewer//sanitized_helper
/usr/bin/evince-thumbnailer
/usr/bin/evince//sanitized_helper
/usr/bin/man
/usr/lib/NetworkManager/nm-dhcp-client.action
/usr/lib/NetworkManager/nm-dhcp-helper
/usr/lib/connman/scripts/dhclient-script
/usr/lib/cups/backend/cups-pdf
/usr/lib/snapd/snap-confine
/usr/lib/snapd/snap-confine//mount-namespace-capture-helper
/usr/sbin/cups-browsed
/usr/sbin/cupsd
/usr/sbin/cupsd//third_party
/usr/sbin/tcpdump
/{,usr/}sbin/dhclient
ippusbxd
lsb_release
man_filter
man_groff
nvidia_modprobe
nvidia_modprobe//kmod
snap-update-ns.core
snap-update-ns.gimp
snap-update-ns.snap-store
snap-update-ns.spotify
snap.core.hook.configure
snap.gimp.gimp
snap.gimp.hook.install
snap.gimp.hook.post-refresh
snap.snap-store.snap-store
snap.snap-store.ubuntu-software
snap.snap-store.ubuntu-software-local-file
snap.spotify.spotify
0 profiles are in complain mode.
3 processes have profiles defined.
3 processes are in enforce mode.
/usr/sbin/cups-browsed (1066)
/usr/sbin/cupsd (980)
/snap/snap-store/454/usr/bin/snap-store (2422) snap.snap-store.ubuntu-software
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.
输出
该命令sudo service mysql start
产生输出
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
该命令的 mysqld 输出journalctrl -xe
为
Jun 12 19:28:26 tehccount mysqld[6655]: 2020-06-12T23:28:26.016428Z 0 [Warning] [MY-010091] [Server] Can't create test file /home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
Jun 12 19:28:26 tehccount mysqld[6655]: 2020-06-12T23:28:26.016478Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20-0ubuntu0.20.04.1) starting as process 6655
Jun 12 19:28:26 tehccount mysqld[6655]: 2020-06-12T23:28:26.018301Z 0 [Warning] [MY-010091] [Server] Can't create test file /home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
Jun 12 19:28:26 tehccount mysqld[6655]: 2020-06-12T23:28:26.018309Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/ is case insensitive
Jun 12 19:28:26 tehccount mysqld[6655]: 2020-06-12T23:28:26.018491Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to '/home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/' (OS errno: 13 - Permission denied)
Jun 12 19:28:26 tehccount mysqld[6655]: 2020-06-12T23:28:26.018547Z 0 [ERROR] [MY-010119] [Server] Aborting
Jun 12 19:28:26 tehccount mysqld[6655]: 2020-06-12T23:28:26.018619Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20-0ubuntu0.20.04.1) (Ubuntu).
Jun 12 19:28:26 tehccount systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
该命令的输出sudo systemctl status mysql.service
是
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2020-06-12 19:28:27 EDT; 5min ago
Process: 6671 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 6679 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Main PID: 6679 (code=exited, status=1/FAILURE)
Status: "Server startup in progress"
Error: 13 (Permission denied)
Jun 12 19:28:27 tehccount systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Jun 12 19:28:27 tehccount systemd[1]: Stopped MySQL Community Server.
Jun 12 19:28:27 tehccount systemd[1]: mysql.service: Start request repeated too quickly.
Jun 12 19:28:27 tehccount systemd[1]: mysql.service: Failed with result 'exit-code'.
Jun 12 19:28:27 tehccount systemd[1]: Failed to start MySQL Community Server.
该命令的输出sudo -u mysql /usr/sbin/mysqld
是
2020-06-12T23:36:08.460482Z 0 [Warning] [MY-010091] [Server] Can't create test file /home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2020-06-12T23:36:08.460535Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20-0ubuntu0.20.04.1) starting as process 6866
2020-06-12T23:36:08.462316Z 0 [Warning] [MY-010091] [Server] Can't create test file /home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2020-06-12T23:36:08.462334Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/ is case insensitive
2020-06-12T23:36:08.462514Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to '/home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/' (OS errno: 13 - Permission denied)
2020-06-12T23:36:08.462555Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-06-12T23:36:08.462622Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20-0ubuntu0.20.04.1) (Ubuntu).
其他测试
使用 导航到预期的 mysql 数据目录cd /home/tehccount/Dropbox/DesignInk\ Digital/Kyle/Development\ Databases/mysql/
,然后使用命令sudo -u mysql touch testfile.txt
成功创建文件/home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/testfile.txt
概括
尽管我尽了最大的努力并每天工作 8 小时,但我一直无法弄清楚为什么这个过程/usr/sbin/mysqld
无法开始。MySQL 应该从 Apparmor 中删除,并且 datadir 的权限设置为神奇的自由777权限。在使用具有 Apparmor 和适当权限的 Linux Mint 之前,我已成功完成此操作。欢迎任何建议,谢谢。
我遇到了同样的错误,我做了与您完全相同的事情并得到了相同的结果。
我正在移动/var/lib/mysql => /media/{user}/data/mysql
我的修复:
我的猜测是我可以将数据目录挂载出来
/media/{user}/
并且应该也可以正常工作提示:如果 AppArmor 阻止了你,它会在
journalctl -xe
.