mysql5.7.17报错:ERROR! The server quit without updating PID file

来源:互联网 发布:加强网络舆情管理通知 编辑:程序博客网 时间:2024/05/29 09:58

今天重装了个虚拟机开发环境(Centos7.3),按照之前的方法安装最新版本的MySQL(5.7.17),在启动的时候报错:

[root@localhost ~]# /sbin/service mysqld start
Starting MySQL.Logging to ‘/data/mysqldata/localhost.localdomain.err’.
ERROR! The server quit without updating PID file (/data/mysqldata/localhost.localdomain.pid).

网上搜索一下,很多人遇到这种情况,并且很多是老版本的,并没有解决我的问题,最后在官网文档找到了答案:

https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

shell> groupadd mysqlshell> useradd -r -g mysql -s /bin/false mysqlshell> cd /usr/localshell> tar zxvf /path/to/mysql-VERSION-OS.tar.gzshell> ln -s full-path-to-mysql-VERSION-OS mysqlshell> cd mysqlshell> mkdir mysql-filesshell> chmod 750 mysql-filesshell> chown -R mysql .shell> chgrp -R mysql .shell> bin/mysql_install_db --user=mysql    # MySQL 5.7.5shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and upshell> bin/mysql_ssl_rsa_setup              # MySQL 5.7.6 and upshell> chown -R root .shell> chown -R mysql data mysql-filesshell> bin/mysqld_safe --user=mysql &# Next command is optionalshell> cp support-files/mysql.server /etc/init.d/mysql.server

其中的 bin/mysqld –initialize –user=mysql 是关键,之前我安装的时候没有带 –user=mysql参数

其它部分的安装见之前的Blog:Centos下编译mysql5.6.16

设置密码

# /data/apps/mysql5.7.17/bin/mysqld_safe --skip-grant-tables &# mysql -uroot -pmysql> update user set authentication_string=password('666666') where user='root';mysql> flush privileges;mysql> quit;# service mysqld restart# mysql -uroot -p666666 

这时如果报:

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

可以再执行一下:

mysql> set password=password('666666');Query OK, 0 rows affected, 1 warning (0.01 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql> exit;Bye

另:
密码 666666 是测试用,请不要在正式环境中用过于简单的密码。

另2:
Centos7.3的开机启动不执行,需要给rc.local加可执行权限。

chmod +x /etc/rc.d/rc.local

另3:
CSDN Blog的Markdown编辑器在Win10 Edge浏览器下完全不能正常使用。

0 0