askubuntu.com, I need some help debugging my MySQL setup! For the past couple years, I have been hosting my local development resources on Dropbox, and it's been working wonderfully. This past week, I decided to wipe my computer and to use Ubuntu instead of Linux Mint this time around (irrelevant, but yay!). So, on to the important details:
Settings
The datadir entry in /etc/mysql/mysql.conf.d/mysqld.cnf is defined as datadir = "/home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql".
The permissions for /home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases 777 (sad face, but I'm trying to eliminate possibilities at this point) and the owner user/group is mysql:mysql, recursively.
I have defined an Apparmor alias in /etc/apparmor.d/tunables/alias as alias /var/lib/mysql/ -> "/home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/",. I have also added entries into /etc/apparmor.d/usr.sbin.mysqld as
# 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,Furthermore, during my testing I removed MySQL from the list of enforcements using the instructions at (How to disable AppArmor for MySQL), so Apparmor should not be affecting the process at all. My output from sudo aa-status is
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.Outputs
The command sudo service mysql start produces the output
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.The mysqld output from the command journalctrl -xe is
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/FAILUREThe output of the command sudo systemctl status mysql.service is
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.The output of the command sudo -u mysql /usr/sbin/mysqld is
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).Other tests
Navigating to the intended mysql datadir using cd /home/tehccount/Dropbox/DesignInk\ Digital/Kyle/Development\ Databases/mysql/, then using the command sudo -u mysql touch testfile.txt successfully creates the file /home/tehccount/Dropbox/DesignInk Digital/Kyle/Development Databases/mysql/testfile.txt
Summary
Despite my best efforts and an 8 hour day of work, I have been unable to figure out why the process /usr/sbin/mysqld cannot start. MySQL should be removed from Apparmor and the permissions of the datadir are set to a magically liberal 777 permissions. I have done this successfully before using Linux Mint with Apparmor and proper permissions. Any suggestions are welcome, and thank you.
1 Answer
I was getting the same error, I did exactly the same things you did and got the same results.
I was moving the /var/lib/mysql => /media/{user}/data/mysql
My fix:
$ sudo chmod 777 /media/{user}/My guess is that I could mount the data directory out of the /media/{user}/ and should work fine too
Hint: If AppArmor is blocking you, it will tell you in the output of journalctl -xe.