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

今天重装了个虚拟机开发环境(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 mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chmod 750 mysql-files
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql    # MySQL 5.7.5
shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up
shell> bin/mysql_ssl_rsa_setup              # MySQL 5.7.6 and up
shell> chown -R root .
shell> chown -R mysql data mysql-files
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> 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 -p
mysql> 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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值