Linux安装mysql时出现
Error occurred: Query against mysql.user table failed when checking the mysql.session.
出现这个错误真的很令人头疼,它会导致:
root@ubuntu:~# systemctl status mysql
● mysql.service
Loaded: masked (/dev/null; bad)
Active: failed (Result: exit-code) since Wed 2019-10-09 16:44:00 UTC; 13min ago
Oct 09 16:43:58 ubuntu systemd[1]: Starting MySQL Community Server...
Oct 09 16:43:58 ubuntu mysqld[73677]: Initialization of mysqld failed: 0
Oct 09 16:43:58 ubuntu systemd[1]: mysql.service: Control process exited, code=exited st
Oct 09 16:44:00 ubuntu systemd[1]: mysql.service: Failed with result 'exit-code'.
Oct 09 16:44:00 ubuntu systemd[1]: Stopped MySQL Community Server.
然后你的mql根本无法启动,这怎么办呢?
其实这个的原因源于我们之前安装mysql时没有把正常安装或者卸载mysql-server卸载不够干净
这时,我们就要把mysql测定的清除
首先:
root@ubuntu:~# rm /var/lib/mysql/ -R #删除库
root@ubuntu:~# rm /etc/mysql/ -R #删除配置文件
root@ubuntu:~# apt-get autoremove mysql* --purge #上传含有mysql相关的包
叮叮当!
已经清除完毕,这时再
root@ubuntu:~# apt-get install mysql-server
root@ubuntu:~# systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-10-09 17:03:57 UTC; 59s ago
Main PID: 109726 (mysqld)
Tasks: 27 (limit: 2290)
CGroup: /system.slice/mysql.service
└─109726 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
Oct 09 17:03:57 ubuntu systemd[1]: Starting MySQL Community Server...
Oct 09 17:03:57 ubuntu systemd[1]: Started MySQL Community Server.
可以发现状态就变成了running,呵呵!又可以为所欲为的使用mysql了!!
如果对你有帮助的话,可以动动小手点个赞哦!