更新Ubuntu 18.4后无法启动mysql服务器

时间:2019-05-29 16:48:26

标签: mysql ubuntu mysql-error-2002

首先,我尝试卸载它们

string = "date file /20190529050003/folder "
regex = re.compile(r'\b\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}\b')
result = regex.findall(string)[0]
'20190529050003'

然后我尝试安装它们

root@thaali:/etc/mysql# sudo apt-get remove --purge mysql*
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package mysql.cnf
E: Couldn't find any package by glob 'mysql.cnf'
E: Couldn't find any package by regex 'mysql.cnf'
E: Unable to locate package mysql.conf.d
E: Couldn't find any package by glob 'mysql.conf.d'
E: Couldn't find any package by regex 'mysql.conf.d'

当我尝试重新启动时会发生这种情况

root@thaali:/etc/mysql# sudo apt-get install mysql-server mysql-client
Reading package lists... Done
Building dependency tree... 50%
Building dependency tree       
Reading state information... Done
mysql-client is already the newest version (5.7.26-0ubuntu0.19.04.1).
mysql-server is already the newest version (5.7.26-0ubuntu0.19.04.1).
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.

这是我尝试使用systemctl时发生的事情

root@thaali:/etc/mysql# 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.

这是我尝试连接时抛出的错误

root@thaali:/etc/mysql# systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2019-05-29 22:07:43 +0530; 6min ago
  Process: 21283 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)

මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Control process exited, code=exited, status=1/FAILURE
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Failed with result 'exit-code'.
මැයි 29 22:07:43 thaali systemd[1]: Failed to start MySQL Community Server.
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Service RestartSec=100ms expired, scheduling restart.
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
මැයි 29 22:07:43 thaali systemd[1]: Stopped MySQL Community Server.
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Start request repeated too quickly.
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Failed with result 'exit-code'.
මැයි 29 22:07:43 thaali systemd[1]: Failed to start MySQL Community Server.

有人可以帮我解决这个问题吗,我在某些地方看到我已经编辑过 etc / my.cnf 来解决这个问题,因为我没有这样的文件

1 个答案:

答案 0 :(得分:0)

这真的很奇怪,因为我没有进行远程升级。有一天,它根本没有用。

当我尝试journalctl -xe时得到了这个

    ...
Oct 05 08:51:26 <servername> mysql-systemd-start[10914]: ERROR: Unable to start MySQL server:
Oct 05 08:51:26 <servername> mysql-systemd-start[10914]: mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
    ...

我通过以下操作对其进行了修复:

sudo mkdir /var/lib/mysql-files

sudo chown -R mysql:mysql /var/lib/mysql-files/

sudo chmod 700 /var/lib/mysql-files/

sudo service mysql restart

重新启动服务实际上并不能解决我遇到的所有问题,所以我以重新启动计算机结束。