MySQL无法重置“root”密码

时间:2016-06-13 13:29:13

标签: mysql linux fedora-21

我试图遵循所有建议here,但没有一个对我有用。我在Fedora mysql-community-server-5.7.9-1.fc21.x86_64

上安装了mysql社区服务器

我曾尝试使用临时密码 sudo grep 'temporary password' mysqld.log但它不会返回任何密码。

我一直在收到错误 Access denied for user 'root'@'localhost' (using password: NO)

执行mysqld_safe --skip-grant-tables

时出现此错误

2016-06-14 10:46:00 3495 mysqld_safe: Logging to '/var/log/mysqld.log'. chown: invalid user: ‘@MYSQLD_USER@’ 2016-06-14 10:46:00 3495 mysqld_safe: The file @libexecdir@/mysqld does not exist or is not executable. Please cd to the mysql installation directory and restart this script from there as follows: ./bin/mysqld_safe& See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information

我无法重置root用户密码。请帮忙。

1 个答案:

答案 0 :(得分:0)

重置MYSQL ROOT PASSWORD(适用于linux用户)

登录root用户并运行

Step 1# /etc/init.d/mysql stop 
Step 2# mysqld_safe --skip-grant-tables & 
Output : Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[6025]: started

Step 3 Login to new terminal (with root user)

   [#] mysql -u root

mysql> use mysql; 
mysql> update user set password=PASSWORD('NEW-ROOT-PASSWORD') where User='root';
mysql> flush privileges; 
mysql> quit

Step 4 # Stop MySQL Server:

/etc/init.d/mysql stop

Step 5 # /etc/init.d/mysql start

mysql -u root -pNEWPASSWORD

---------------------完成----------