在学习阶段偶尔会删除/var/lib/mysql/*目录来达到清除数据库管理员账户和密码的目的。but,对于新手来说经常会不小心删除/var/lib/mysql目录,导致重启mysql时找不到/var/lib/mysql。
解决方法如下:
mkdir /var/lib/mysq
chown mysql:mysql /var/lib/mysql
systemctl start mysql
此时如果还是失败,并产生如下提示信息:
May 17 19:50:53 localhost.localdomain dbus-daemon[1798]: [system] Activating service name='org.fedoraproject.Setroubleshootd' requested by ':1.28' (uid=0 pid=1757 comm="/usr/sbin/sedispatch " label="syst>
May 17 19:50:54 localhost.localdomain dbus-daemon[1798]: [system] Successfully activated service 'org.fedoraproject.Setroubleshootd'
May 17 19:50:54 localhost.localdomain setroubleshoot[4576]: failed to retrieve rpm info for /var/lib/mysql/ibdata1
May 17 19:51:00 localhost.localdomain setroubleshoot[4576]: Plugin Exception catchall_labels
May 17 19:51:00 localhost.localdomain setroubleshoot[4576]: SELinux is preventing /usr/libexec/mysqld from getattr access on the file /var/lib/mysql/ibdata1. For complete SELinux messages run: sealert -l>
May 17 19:51:00 localhost.localdomain platform-python[4576]: SELinux is preventing /usr/libexec/mysqld from getattr access on the file /var/lib/mysql/ibdata1
则是由于SElinux权限导致,解决如下:
restorecon -Rv /var/lib/mysql
就此问题解决!