Mysql permission denied linux

Ubuntu 20.04 MySQL Datadir Permissions (Errno 13)

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 /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

Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details. 
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 
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. 
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.

Читайте также:  Температура процессора linux утилита

Источник

[РЕШЕНО] Errcode: 13 – Permission denied в MySQL

Сегодня расскажу, как можно исправить ошибку Errcode: 13 – Permission denied в MySQL.

mysqld: Can't create/write to file '/tmp/ibJCvPPz' (Errcode: 13 - Permission denied) 2018-06-13T21:53:50.867516Z 0 [ERROR] InnoDB: Unable to create temporary file; errno: 13 2018-06-13T21:53:50.867532Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2018-06-13T21:53:50.867546Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 2018-06-13T21:53:50.867556Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2018-06-13T21:53:50.867567Z 0 [ERROR] Failed to initialize builtin plugins. 2018-06-13T21:53:50.867576Z 0 [ERROR] Aborting

Если ваш MySQL выдаёт данную ошибку, то причина тут одна – MySQL не может произвести запись в директорию /tmp. Вызвана она изменение прав на данную директорию.

Посмотреть описание ошибок MySQL также можно командой perror №_ошибки

Исправляем ошибку Errcode: 13 – Permission denied

Давайте исправим данную ошибку. Заходим в терминал и набираем следующее:

После данной процедуры MySQL стартует без ошибок.

Если есть вопросы, то пишем в комментариях.

Также можете вступить в Телеграм канал, ВКонтакте или подписаться на Twitter. Ссылки в шапке страницы.
Заранее всем спасибо.

Если вы нашли ошибку, пожалуйста, выделите фрагмент текста и нажмите Ctrl+Enter.

linux-logo

Сегодня в статье настроим и русифицируем Ubuntu Server 16.04/18.04/20.04. Чтобы поддерживался русский язык, и перевод системы стал русским

linux-logo

В этой статье рассмотрим пример обновления Ubuntu Server 16.04 до Ubuntu Server 18.04 Все наши действия нам придется выполнять из Читать

network-logo

В этой статье рассмотрим пример как можно переименовать сетевые интерфейсы в дистрибутивах Linux. После обновления systemd (частью которого является udev) Читать

Сегодня поговорим об ошибке ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ выдаваемой при попытке подключится к MYSQL ERROR 1045 Читать

Читайте также:  Python gui linux windows

Источник

why I cannot cd into /var/lib/mysql

sudo -i solved this issue for me, on ubuntu with a directory i ran the following on sudo chown -R mysql:mysql .

mysql user is the only one that can access to the directory, you can use root to access there and change permissions, or you can change the directory permissions to 740 with

permissions are divided in 3 parts user/group/else. and you have

so the «owner» has read(4) + write(2) + execute(1) = 7 permissions in that directory

You should use 750 or 755 if you want others to access the directory. 740 is sufficient for members of the right group to read the immediate directory listing and nothing more. The execute bit is more important here.

mysql group has no access to that directory. The rights for the mysql user are rwx , but group and others get — , so being in the mysql group doesn’t give you what you want.

I see, so to cd into it I need either to add the mysql group, or sudo -i and to then cd mysql. Do you think it’s a bad idea the former solution regarding security?

It may be a bad idea from the point of view of packaging — when you upgrade mysql it could reinstall the old privileges on /var/lib/mysql.

The mysql group doesn’t have permissions on the directory, only the mysql user.

From given inputs it is clear that only owner mysql has read, write, execute permission on /var/lib/mysql directory.

And current login user — ravas is part of mysql group. Hence ravas user can cd to /var/lib/mysql directory if group mysql has x (ie execute) permission on /var/lib/mysql .

Читайте также:  Ред ос это линукс

Hence chmod g+rx /var/lib/mysql OR chmod 750 /var/lib/mysql would allow ravas user to cd to /var/lib/mysql and read directory contents (ie. list files)

Each file and directory has three user based permission groups:

owner — The Owner permissions apply only the owner of the file or directory, they will not impact the actions of other users.

group — The Group permissions apply only to the group that has been assigned to the file or directory, they will not effect the actions of other users.

all users — The All Users permissions apply to all other users on the system, this is the permission group that you want to watch the most.

drwx—— 13 mysql mysql 4096 Feb 10 22:32 mysql

the above show mysql folder Permissions is 700, So mysql user have all read,write and execute permission. mysql group have none permission. although, ravas user belong mysql group. haven’t permission.

Источник

Оцените статью
Adblock
detector