我也遇到这个问题,登陆的时候提示一样, 但是启动服务提示如下 Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).造成原因的问题是,我直接把服务器重启了.mysql就启动不了了. 之前一直好用,不知道这么解决,网上找了好多也没得解决
创建之后有了新的报错:[root@localhost my.cnf.d]# touch /var/lib/mysql/mysql.sock touch: cannot touch ‘/var/lib/mysql/mysql.sock’: No such file or directory [root@localhost my.cnf.d]# mkdir -p /var/lib/mysql [root@localhost my.cnf.d]# touch /var/lib/mysql/mysql.sock [root@localhost my.cnf.d]# service mysql start Redirecting to /bin/systemctl start mysql.service Failed to issue method call: Unit mysql.service failed to load: No such file or directory. [root@localhost my.cnf.d]# systemctl start mysql.service Failed to issue method call: Unit mysql.service failed to load: No such file or directory. [root@localhost my.cnf.d]#
检查一下MYSQL的错误日志,看其中的信息是什么。
配置文件/etc/my.cnf,显示的log文件位置是 /var/log/mariadb/mariadb.log GNU nano 2.3.1 File: /etc/my.cnf[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd[mysqld_safe] log-error=/var/log/mariadb/mariadb.log pid-file=/var/run/mariadb/mariadb.pid# # include all files from the config directory # !includedir /etc/my.cnf.d 查看 /var/log/mariadb/mariadb.log :内容是空的[root@localhost mariadb]# file /var/log/mariadb/mariadb.log /var/log/mariadb/mariadb.log: empty [root@localhost mariadb]# ls -la /var/log/mariadb/mariadb.log -rw-r----- 1 mysql mysql 0 Sep 8 18:52 /var/log/mariadb/mariadb.log [root@localhost mariadb]#
不存在那个文件。[root@webmaster ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib
/mysql/mysql.sock' (2)
[root@webmaster ~]# find / -name *mysql*sock*
[root@webmaster ~]# find / -name *mysql.sock*
[root@webmaster ~]# find / -name *sock
[root@webmaster ~]#
如果重启失败,那么需要检查错误日志查找原因。另外重启前,可以考虑删除var/lib/mysql下面的ib_logfile0、ib_logfile1、ib_logfile2等文件,之后再启动。
但是启动服务提示如下
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).造成原因的问题是,我直接把服务器重启了.mysql就启动不了了. 之前一直好用,不知道这么解决,网上找了好多也没得解决
然后再重启服务试试看看能不能自动生成这个文件.
创建之后有了新的报错:[root@localhost my.cnf.d]# touch /var/lib/mysql/mysql.sock
touch: cannot touch ‘/var/lib/mysql/mysql.sock’: No such file or directory
[root@localhost my.cnf.d]# mkdir -p /var/lib/mysql
[root@localhost my.cnf.d]# touch /var/lib/mysql/mysql.sock
[root@localhost my.cnf.d]# service mysql start
Redirecting to /bin/systemctl start mysql.service
Failed to issue method call: Unit mysql.service failed to load: No such file or
directory.
[root@localhost my.cnf.d]# systemctl start mysql.service
Failed to issue method call: Unit mysql.service failed to load: No such file or
directory.
[root@localhost my.cnf.d]#
配置文件/etc/my.cnf,显示的log文件位置是 /var/log/mariadb/mariadb.log GNU nano 2.3.1 File: /etc/my.cnf[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
查看 /var/log/mariadb/mariadb.log :内容是空的[root@localhost mariadb]# file /var/log/mariadb/mariadb.log
/var/log/mariadb/mariadb.log: empty
[root@localhost mariadb]# ls -la /var/log/mariadb/mariadb.log
-rw-r----- 1 mysql mysql 0 Sep 8 18:52 /var/log/mariadb/mariadb.log
[root@localhost mariadb]#
也用过 yum install mariadb* (291MB)
[root@localhost ~]# yum install mariadb-server mariadb
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.linode.com
* extras: mirrors.linode.com
* updates: mirrors.linode.com
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.37-1.el7_0 will be installed
---> Package mariadb-server.x86_64 1:5.5.37-1.el7_0 will be installed
--> Finished Dependency ResolutionDependencies Resolved==========================================================================================================
Package Arch Version Repository Size
==========================================================================================================
Installing:
mariadb x86_64 1:5.5.37-1.el7_0 updates 8.9 M
mariadb-server x86_64 1:5.5.37-1.el7_0 updates 11 MTransaction Summary
==========================================================================================================
Install 2 PackagesTotal download size: 20 M
Installed size: 104 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): mariadb-server-5.5.37-1.el7_0.x86_64.rpm | 11 MB 00:00:01
(2/2): mariadb-5.5.37-1.el7_0.x86_64.rpm | 8.9 MB 00:00:01
----------------------------------------------------------------------------------------------------------
Total 12 MB/s | 20 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:mariadb-5.5.37-1.el7_0.x86_64 1/2
Installing : 1:mariadb-server-5.5.37-1.el7_0.x86_64 2/2
Verifying : 1:mariadb-server-5.5.37-1.el7_0.x86_64 1/2
Verifying : 1:mariadb-5.5.37-1.el7_0.x86_64 2/2Installed:
mariadb.x86_64 1:5.5.37-1.el7_0 mariadb-server.x86_64 1:5.5.37-1.el7_0Complete!
[root@localhost ~]# whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
[root@localhost ~]# whereis mysqld
mysqld: /usr/libexec/mysqld /usr/share/man/man8/mysqld.8.gz
[root@localhost ~]# systemctl start mariadb.service
Job for mariadb.service failed. See 'systemctl status mariadb.service' and 'journalctl -xn' for details. 错误日志:[root@localhost ~]# systemctl status mariadb.service
mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled)
Active: failed (Result: exit-code) since Mon 2014-09-08 19:28:19 HKT; 18s ago
Process: 16635 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=1/FAILURE)Sep 08 19:28:19 localhost mariadb-prepare-db-dir[16635]: https://mariadb.com/kb/en/installing-system-...db
Sep 08 19:28:19 localhost mariadb-prepare-db-dir[16635]: MariaDB is hosted on launchpad; You can find...nd
Sep 08 19:28:19 localhost mariadb-prepare-db-dir[16635]: email lists at http://launchpad.net/maria
Sep 08 19:28:19 localhost mariadb-prepare-db-dir[16635]: Please check all of the above before submitt...rt
Sep 08 19:28:19 localhost mariadb-prepare-db-dir[16635]: at http://mariadb.org/jira
Sep 08 19:28:19 localhost mariadb-prepare-db-dir[16635]: Initialization of MySQL database failed.
Sep 08 19:28:19 localhost mariadb-prepare-db-dir[16635]: Perhaps /etc/my.cnf is misconfigured.
Sep 08 19:28:19 localhost systemd[1]: mariadb.service: control process exited, code=exited status=1
Sep 08 19:28:19 localhost systemd[1]: Failed to start MariaDB database server.
Sep 08 19:28:19 localhost systemd[1]: Unit mariadb.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#