Main > MySQL > MySQL 5.7: Could not create unix socket lock file /var/run/mysqld/mysqld.sock.lock

MySQL 5.7: Could not create unix socket lock file /var/run/mysqld/mysqld.sock.lock

25.11.2019 0 comments » Views: 782

mysql

После обновления MySQL с версии 5,6 на версию 5,7 столкнулся с тем, что MySQL перестала запускаться. В логе была вот такая ошибка: [ERROR] Could not create unix socket lock file /var/run/mysqld/mysqld.sock.lock..

Вот так выглядит ошибка в /var/log/mysql/error.log

Первым делом я проверил, что указанная папка существует и у нее правильный пользователь (mysql) и есть права на запись

в моем случае все было в порядке.

Я погуглил и наткнулся на напоминание, что для убунту надо этот файл добавить в apparmor, это я и сделал

и перезапускаем apparmor и mysql

К сожалению, на этом приключения не закончились, по прежнему была та же ошибка в логе mysql. Тогда я погуглил по ключевику "apparmor mysql" и нашел подсказку - смотреть в syslog. Заглянул туда и увидел ошибку чтения других файлов

в атрибуте name мы видим к каким файлам mysql пытается получить доступ. Вносим их так же в apparmor

и рестартуем

после этого mysql успешно запустился.

Т.е. алгоритм решения тут такой:

  1. Пробуем запустить mysql и получаем ошибку
  2. Проверяем существование папки и права на нее
  3. Проверяем не закончилось ли место на диске
  4. Смотрим в /var/log/mysql/error.log и видим ошибку записи
  5. Смотрим в /var/log/syslog и добавляем в /etc/apparmor.d/usr.sbin.mysqld те пути, куда не хватает доступа
  6. Перезапускаем apparmor
  7. Пробуем запустить MySQL, повторяем пункты 4-7.

-- [добавлено] --

В конфиге apparmor-а, после пути указывается флаг доступа, вот возможные варианты

  • r - read - permission to read data
  • w - write - permission to create, delete, write to a file and extend it
  • a - append - permission to create, and extend a file. The append permission is limited that it only gives permission for applications to open a file with O_APPEND, it can not be used to enforce a generic file write is append only. If an application only has the append permission in the profile and it tries to write to the file even if it is an appending write, the write will be failed.
  • l - link - permission to link to a file (combined with /** to determine if permissions apply to subtree)
  • k - lock - permission to lock a file, is combined with write perm to determine if it has permission to take exclusive lock
  • m - memory map executable - permission to memory map a file executable
  • x - executable - determines if a file is executable, allow forms of the rule must be accompanied by x qualifiers. When specified as part of an allow rule it must be accompanied by qualifiers.

Более подробно вот тут: https://gitlab.com/apparmor/apparmor/wikis/AppArmor_Core_Policy_Reference

 

Author: | Rating: 4/5 | Tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

Allowed HTML-tags: <a>, <code>, <i>, <em>, <strong>, <b>, <u>, <strike>