Mysql更改数据目录之后无法启动

配置mysql 数据目录之后,重新启动服务,发现启动失败。
查询服务状态:

systemctl status -l mysqld
[root@PROD-service160 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Wed 2017-08-23 14:28:18 CST; 9s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 9643 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
  Process: 9624 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)

Aug 23 14:28:18 PROD-service160 systemd[1]: Failed to start MySQL Server.
Aug 23 14:28:18 PROD-service160 systemd[1]: Unit mysqld.service entered failed state.
Aug 23 14:28:18 PROD-service160 systemd[1]: mysqld.service failed.
Aug 23 14:28:18 PROD-service160 systemd[1]: mysqld.service holdoff time over, scheduling restart.
Aug 23 14:28:18 PROD-service160 systemd[1]: start request repeated too quickly for mysqld.service
Aug 23 14:28:18 PROD-service160 systemd[1]: Failed to start MySQL Server.
Aug 23 14:28:18 PROD-service160 systemd[1]: Unit mysqld.service entered failed state.
Aug 23 14:28:18 PROD-service160 systemd[1]: mysqld.service failed.

网上找了一下,几乎都是说新的目录没有权限导致,需要设置一下目录权限

chown -R mysql:mysql /data/mysql

但是我的目录权限已经修改过了,没有问题。看来遇到疑难杂症了,可能有其他问题。这个时候突然想到mysql配置了日志,为什么不去看一下日志。
打开/var/log/mysqld.log,赫然发现一些错误信息:

2017-08-23T06:36:23.579703Z 0 [Note] Binlog end
2017-08-23T06:36:23.579784Z 0 [Note]
2017-08-23T06:36:24.079916Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-23T06:36:24.080204Z 0 [Warning] Can't create test file /data/mysql/data/PROD-service160.lower-test
2017-08-23T06:36:24.080259Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.18-log) starting as process 9914 ...
2017-08-23T06:36:24.080295Z 0 [ERROR] Can't find error-message file '/data/mysql/share/mysql/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2017-08-23T06:36:24.081125Z 0 [Warning] Can't create test file /data/mysql/data/PROD-service160.lower-test
2017-08-23T06:36:24.081163Z 0 [Warning] Can't create test file /data/mysql/data/PROD-service160.lower-test
mysqld: File './mysql-bin.index' not found (Errcode: 13 - Permission denied)
2017-08-23T06:36:24.081577Z 0 [ERROR] Aborting

看来是errmsg文件找不到,我去目录下看了,确实没有。
我在根目录下搜索这个文件,得到以下的结果:

./usr/share/mysql/bulgarian/errmsg.sys
./usr/share/mysql/czech/errmsg.sys
./usr/share/mysql/danish/errmsg.sys
./usr/share/mysql/dutch/errmsg.sys
./usr/share/mysql/english/errmsg.sys
./usr/share/mysql/estonian/errmsg.sys
./usr/share/mysql/french/errmsg.sys
./usr/share/mysql/german/errmsg.sys
./usr/share/mysql/greek/errmsg.sys
./usr/share/mysql/hungarian/errmsg.sys
./usr/share/mysql/italian/errmsg.sys
./usr/share/mysql/japanese/errmsg.sys
./usr/share/mysql/korean/errmsg.sys
./usr/share/mysql/norwegian/errmsg.sys
./usr/share/mysql/norwegian-ny/errmsg.sys
./usr/share/mysql/polish/errmsg.sys
./usr/share/mysql/portuguese/errmsg.sys
./usr/share/mysql/romanian/errmsg.sys
./usr/share/mysql/russian/errmsg.sys
./usr/share/mysql/serbian/errmsg.sys
./usr/share/mysql/slovak/errmsg.sys
./usr/share/mysql/spanish/errmsg.sys
./usr/share/mysql/swedish/errmsg.sys
./usr/share/mysql/ukrainian/errmsg.sys

一看名字,就能猜出来和语言有关。
5.5版本的语法,需要在配置文件中修改配置语言选项

language=/usr/share/mysql/english

我现在是5.7版本,直接copy过去好了。
重启,结果还是不行,又查日志。

mysqld: File './mysql-bin.index' not found (Errcode: 13 - Permission denied)

你可能感兴趣的:(Mysql更改数据目录之后无法启动)