mysql error 1130 hy 000:Host'localhost'is not allowed to connect to this mysql serverソリューション

2082 ワード


ERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this MySQL server
D:\Wamp\mysql-5.6.21\bin>mysql.exe -uroot -p
Enter password:
ERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this MySQL server

 
ここではrootアカウントにローカルデータベースへのアクセス権がないため、データベースに接続できません.grantを使用してrootアカウントに権限を与える必要があります.
権限を付与する前にデータベースにログインし、skip-grant-tablesパラメータを使用する必要があります.
skip-grant-tablesはその名の通り、データベース起動時にジャンプ権限テーブルの制限があり、パスワードを検証せずに直接ログインします.
 
編集my.ini,[mysqld]のセグメントにskip-grant-tablesを付ける
[mysqld] 
datadir=/var/lib/mysql 
socket=/var/lib/mysql/mysql.sock 
skip-name-resolve 
skip-grant-tables 

 
一時的なソリューションは、mysql rootユーザーのパスワードを忘れた場合にも使用できます.セキュリティも保証しにくいです.
 
rootアカウントにログインすると、パスワードを入力する必要がなく、grantにアクセスできます.
mysql> grant all privileges on *.* to root@'localhost' identified by "123456";

 
エラーERROR 1290(HY 000):The MySQL server is running with the--skip-grant-tables option so it cannot execute this statement
権限をリフレッシュするだけでいいflush privileges;
それから授権命令を実行すればいいです.
 
最後に、プロファイルからskip-grant-tablesパラメータを削除し、MySQLサービスを再起動してください.
 
転載先:https://www.cnblogs.com/rnckty/p/5577818.html