MySQL Error::'Access denied for user'root'@'localhost'エラー解決
2352 ワード
ソース:https://stackoverflow.com/questions/41645309/mysql-error-access-denied-for-user-rootlocalhost
用:sudo mysql
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘root’; 解決した
インストールサービスでパスワードの設定などの指示がない場合はパスワードエラーです.解決策は以下の通り
デフォルトのユーザー名パスワードでログイン:mysql-u debian-sys-maint-p
原文抜粋:
Asked 3 years, 2 months ago
$ ./mysqladmin -u root -p ‘redacted’ Enter password:
How can I fix this?
Answers Open & Edit Add Restart Mysql You should be able to login to mysql now using the below command mysql -u root -p Run Set new password by Go back to/etc/my.cnf and remove/comment skip-grant-tables Restart Mysql Now you will be able to login with the new password
All solutions I found were much more complex than necessary and none worked for me. Here is the solution that solved my problem. No need to restart mysqld or start it with special privileges.
With a single query we are changing the auth_plugin to mysql_native_password and setting the root password to root (feel free to change it in the query)
Now you should be able to login with root. More information can be found in mysql documentation
(exit mysql console with Ctrl + D or by typing exit)
用:sudo mysql
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘root’; 解決した
インストールサービスでパスワードの設定などの指示がない場合はパスワードエラーです.解決策は以下の通り
sudo vim /etc/mysql/debian.cnf
mysqlファイルにアクセスして元のパスワードを表示[client]
host = localhost
user = debian-sys-maint
password = 1v5Fuo0zjy6GkSCz
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = 1v5Fuo0zjy6GkSCz
socket = /var/run/mysqld/mysqld.sock
デフォルトのユーザー名パスワードでログイン:mysql-u debian-sys-maint-p
原文抜粋:
Asked 3 years, 2 months ago
$ ./mysqladmin -u root -p ‘redacted’ Enter password:
mysqladmin: connect to server at 'localhost' failed error:
'Access denied for user 'root'@'localhost' (using password: YES)'
How can I fix this?
Answers
/etc/my.cnf
o r /etc/mysql/my.cnf
, depending on your distro. skip-grant-tables
under [mysqld]
mysql> flush privileges;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';
mysql -u root -p
All solutions I found were much more complex than necessary and none worked for me. Here is the solution that solved my problem. No need to restart mysqld or start it with special privileges.
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
With a single query we are changing the auth_plugin to mysql_native_password and setting the root password to root (feel free to change it in the query)
Now you should be able to login with root. More information can be found in mysql documentation
(exit mysql console with Ctrl + D or by typing exit)