ERROR 1044 (42000)Access denied for user @localhost to database
阿新 • • 發佈:2019-01-24
ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘demo’
不管輸入什麼都是提示許可權不夠
mysql> create database sufadi;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'sufadi'
原因
預設情況是匿名使用者登陸,所以我們需要設定一個密碼,然後每次需要登陸以下並進入
D:\python3-webapp-Su\www>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 48
Server version: 5.6.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
設定密碼
管理員身份執行
進入安裝目錄的bin檔案,右鍵選擇管理員身份執行mysql.exe
設定密碼
UPDATE user SET Password=PASSWORD(‘123456’) WHERE user=’root’;
mysql> UPDATE user SET Password=PASSWORD('123456') WHERE user= 'root';
Query OK, 3 rows affected (0.03 sec)
Rows matched: 3 Changed: 3 Warnings: 0
重新整理一下
flush privileges;
mysql> flush privileges
-> ;
Query OK, 0 rows affected (0.01 sec)
cmd視窗重新登陸一下
mysql -u root -p
輸入密碼
C:\Users\admin>mysql -u root -p
Enter password:
登陸成功
C:\Users\admin>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 49
Server version: 5.6.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
建立一個數據庫
mysql> create database pythondb;
Query OK, 1 row affected (0.01 sec)
show databases
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| demo |
| mysql |
| performance_schema |
| pythondb |
| sufadi |
| test |
+--------------------+
7 rows in set (0.00 sec)