MySQL 5.7 安装完成后,首次登陆的几个问题

Server:CentOS 7.0

MySQL : 5.7.20 MySQL Community Server (GPL)

1.首次登陆后修改密码:

根据安装时的选择不同,有mysqld_safe用mysqld_safe,没有就用mysqld。正常安装都应该在/usr/sbin目录下

a)启动mysql

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

b)无密码进入msyql

mysql -u root mysql

c) 修改密码

UPDATE user SET Password=PASSWORD('newpassword') where USER='root';   

会发现这个错误:ERROR 1054 (42S22): Unknown column 'Password' in 'field list'

最新版的mysql中,该命令应该改为:

UPDATE user SET authentication_string=PASSWORD('newpassword') where USER='root';  

d) 刷新退出

flush privileges; 

exit;

 2.每次登陆提示需要修改密码:

退出后通过密码登录发现无论做什么操作都会提示

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

于是,只能再次设置

UPDATE user SET PASSWORD=PASSWORD('newpassword')

但是退出后,再次进入,仍然会有这个提示。非常坑........

解决办法:

UPDATE user SET authentication_string=PASSWORD('newpassword') where USER='root' and host='root' or host='localhost';

貌似是把所有的空密码都设置为有效的密码才行,mysql 5.6还没有这种限制。5.7上现在有了

flush privileges; exit之后再登录就不会提示修改密码了。

3. 无法启动报错

查看mysqld.log,发现如下错误记录

====================================

InnoDB: Unable to lock ./ibdata1, error: 11 

InnoDB: Check that you do not already have another mysqld process

 ===================================

root cause:启动文件,被另一个进程占用。其实大多数情况是mysqld重启的时候,之前的资源没有完全释放。

solution: 

1)ps aux |grep mysq*  #找到锁住资源的进程

2)kill -s 9 进程号  # 杀死进程

3)重启mysqld即可

4. 如果没有mysqld_safe:

通常,mysql安装成功后会给root生成一个默认的密码,通过以下命令查看。

sudo grep 'temporary password' /var/log/mysqld.log

原文地址:https://www.cnblogs.com/shizouwei/p/7976172.html