mysql初始密码问题,"Access denied

2017-05-22  本文已影响148人  红茶绅士

出现的问题:

Access denied for user 'root'@'localhost' (using password: YES)

出现的原因:

当时直接从MySQL官方网站下载的Community Server 5.6.3版本,一路next下来也没有提示输入密码什么的,所以只能通过命令去重置密码了.

解决方法

$ cd /usr/local/mysql/bin/`
$ ./mysqld_safe --skip-grant-tables --skip-networking &
cd /usr/local/mysql/bin/
$ mysql -u root
show databases;
数据库@2x.png
show columns from mysql.user;
user表结构@2x.png
UPDATE mysql.user SET Password=PASSWORD(’新密码’) WHERE User=’root’;
FLUSH PRIVILEGES;
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 547
Server version: 5.6.36 MySQL Community Server (GPL)

网上搜索比较多的是5.7.*的版本,用户表结构没有password字段,需要设置 authentication_string

上一篇 下一篇

猜你喜欢

热点阅读