设置

设置

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.mysqldas中添加了条目

# 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,

此外,在测试期间,我按照以下说明从强制列表中删除了 MySQL(如何禁用 MySQL 的 AppArmor),因此 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 datadir cd /home/tehccount/Dropbox/DesignInk\ Digital/Kyle/Development\ Databases/mysql/,然后使用命令sudo -u mysql touch testfile.txt成功创建文件/home/tehccount/Dropbox/DesignInk Digital/Kyle/开发数据库/mysql/testfile.txt

概括

尽管我尽了最大努力,并且连续工作了 8 个小时,我还是无法弄清楚为什么该进程/usr/sbin/mysqld无法启动。应该从 Apparmor 中删除 MySQL,并将数据目录的权限设置为神奇的自由权限777权限。我之前使用 Linux Mint 和 Apparmor 以及适当的权限成功完成了此操作。欢迎提出任何建议,谢谢。

答案1

我遇到了同样的错误,我做了和你完全相同的事情并得到了相同的结果。

我正在移动/var/lib/mysql=>/媒体/ {用户} /数据/mysql

我的解决方法:

$ sudo chmod 777 /media/{user}/

我猜我可以将数据目录挂载出来,/media/{user}/并且应该也可以正常工作

提示:如果 AppArmor 阻止了您,它会在输出中告诉您journalctl -xe

答案2

我在使用 Prisma 进行迁移时发现了这个问题。之后,我运行了:

sudo /opt/lampp/bin/mysql_upgrade 

...我的问题解决了。

我从这里得到这个解决方案这个 Stack Overflow 问题

相关内容