环境:CentOS7
命令:
systemctl restart mariadb
错误信息:
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
使用journalctl -xe查看:
-- Unit mariadb.service has begun starting up.
Aug 22 01:47:03 localhost.localdomain mariadb-prepare-db-dir[3840]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Aug 22 01:47:03 localhost.localdomain mariadb-prepare-db-dir[3840]: If this is not the case, make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
Aug 22 01:47:03 localhost.localdomain mysqld_safe[3874]: 230822 01:47:03 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.
Aug 22 01:47:03 localhost.localdomain mysqld_safe[3874]: 230822 01:47:03 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Aug 22 01:47:09 localhost.localdomain systemd[1]: mariadb.service: control process exited, code=exited status=1
Aug 22 01:47:09 localhost.localdomain systemd[1]: Failed to start MariaDB database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mariadb.service has failed.
--
-- The result is failed.
Aug 22 01:47:09 localhost.localdomain systemd[1]: Unit mariadb.service entered failed state.
Aug 22 01:47:09 localhost.localdomain systemd[1]: mariadb.service failed.
Aug 22 01:47:09 localhost.localdomain polkitd[523]: Unregistered Authentication Agent for unix-process:3832:19493 (system bus name :1.70, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
原因
1、本机本身就安装了MySQL,当然和mariadb是冲突的
2、安装了Docker,Docker里面运行了MySQL并且映射了主机的3306端口,挂载了主机的配置和数据文件。
所以无法停止和启动mariadb。
检查命令
netstat -an|grep 3306
ps -ef|grep mysql
whereis mysql
如果端口监听、有进程、有文件,肯定是已经安装过了。
解决办法:
1、直接使用现成的MySQL,密码也是123456。不需要重复安装。
关键字:
MySQL