Mysql 5.5 原始碼安裝後建立使用者報錯"ERROR 1045 (28000): Access denied for user"
安裝MySQL後,root使用者可設定密碼登入,其他新建的使用者不能透過密碼登入,只能不輸入密碼登入,而且對新建使用者的授權均無效。
--建立一個庫和使用者
mysql> create database fire;
Query OK, 1 row affected (0.00 sec)
mysql> create user neo identified by 'Mysql#2015';
Query OK, 0 rows affected (0.00 sec)
mysql> grant select,create,update,delete on fire.* to neo;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
--使用新使用者登入報錯
[root@localhost data]# ./bin/mysql -u neo -p"Mysql#2015"
ERROR 1045 (28000): Access denied for user 'neo'@'localhost' (using password: YES)
--但是不輸入密碼卻可以登入
[root@localhost software]# ./bin/mysql -uneo
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.5.48-log production environment
Copyright (c) 2000, 2016, 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> show grants;
+--------------------------------------+
| Grants for @localhost |
+--------------------------------------+
| GRANT USAGE ON *.* TO ''@'localhost' |
+--------------------------------------+
1 row in set (0.00 sec)
報錯原因:Mysql使用原始碼安裝後,資料庫中存在匿名使用者,可以透過任意使用者名稱不輸入密碼即可登入資料庫。
mysql> select host,user,password from mysql.user where (user) not in ('root');
+-----------------------+------+-------------------------------------------+
| host | user | password |
+-----------------------+------+-------------------------------------------+
| localhost | | |
| localhost.localdomain | | |
| % | neo | *CC4C777F1511C297751B78287D6E05345D227819 |
| % | test | *443EF031E558E317B19BAD70BDF4E25FA73A89A7 |
+-----------------------+------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql> select host,user,password from mysql.user where (user) not in ('root','neo','test');
+-----------------------+------+----------+
| host | user | password |
+-----------------------+------+----------+
| localhost | | |
| localhost.localdomain | | |
+-----------------------+------+----------+
2 rows in set (0.00 sec)
解決方法:刪除匿名使用者。
mysql> delete from mysql.user where (user) not in ('root','neo','test');
Query OK, 2 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
之後新建立的使用者即可正常登入到資料庫
[root@localhost software]# ./bin/mysql -uneo -p'Mysql#2015'
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.48-log production environment
Copyright (c) 2000, 2016, 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> show grants;
+-----------------------------------------------------------------+
| Grants for neo@% |
+-----------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'neo'@'%' IDENTIFIED BY PASSWORD <secret> |
| GRANT SELECT, INSERT, DELETE, CREATE ON `fire`.* TO 'neo'@'%' |
+-----------------------------------------------------------------+
2 rows in set (0.00 sec)
[root@localhost data]# ./bin/mysql -u neo -p"Mysql#2015"
ERROR 1045 (28000): Access denied for user 'neo'@'localhost' (using password: YES)
--但是不輸入密碼卻可以登入
[root@localhost software]# ./bin/mysql -uneo
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.5.48-log production environment
Copyright (c) 2000, 2016, 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> show grants;
+--------------------------------------+
| Grants for @localhost |
+--------------------------------------+
| GRANT USAGE ON *.* TO ''@'localhost' |
+--------------------------------------+
1 row in set (0.00 sec)
mysql> select host,user,password from mysql.user where (user) not in ('root');
+-----------------------+------+-------------------------------------------+
| host | user | password |
+-----------------------+------+-------------------------------------------+
| localhost | | |
| localhost.localdomain | | |
| % | neo | *CC4C777F1511C297751B78287D6E05345D227819 |
| % | test | *443EF031E558E317B19BAD70BDF4E25FA73A89A7 |
+-----------------------+------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql> select host,user,password from mysql.user where (user) not in ('root','neo','test');
+-----------------------+------+----------+
| host | user | password |
+-----------------------+------+----------+
| localhost | | |
| localhost.localdomain | | |
+-----------------------+------+----------+
2 rows in set (0.00 sec)
解決方法:刪除匿名使用者。
mysql> delete from mysql.user where (user) not in ('root','neo','test');
Query OK, 2 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@localhost software]# ./bin/mysql -uneo -p'Mysql#2015'
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.48-log production environment
Copyright (c) 2000, 2016, 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> show grants;
+-----------------------------------------------------------------+
| Grants for neo@% |
+-----------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'neo'@'%' IDENTIFIED BY PASSWORD <secret> |
| GRANT SELECT, INSERT, DELETE, CREATE ON `fire`.* TO 'neo'@'%' |
+-----------------------------------------------------------------+
2 rows in set (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2079518/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 報錯”ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)”Errorlocalhost
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:YES)Errorlocalhost
- Linux錯誤 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)LinuxErrorlocalhost
- MySQL 8.0.13 密碼問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)MySql密碼Errorlocalhost
- 解決Mysql:ERROR 1045 (28000):Access denied for user ‘root‘@‘localhost‘ (using password: NO)的方法MySqlErrorlocalhost
- Ubuntu18.04:mysql:ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘UbuntuMySqlErrorlocalhost
- MySQL使用普通使用者訪問返回ERROR 1698 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- ERROR 1045 (28000): ProxySQL Error: 報錯ErrorSQL
- mysql 1045, "Access denied for user 'root'@'localhost' (using password: NO)"MySqllocalhost
- Mysql資料庫報ERROR 1045 (28000)報錯及MySQL忘記密碼找回MySql資料庫Error密碼
- vue專案中連線MySQL時,報錯ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password:YES)VueMySqlErrorlocalhost
- mysql登入報錯提示:ERROR 1045 (28000)的解決方法MySqlError
- Access denied for user 'default'@'%' to database 'shop'報錯Database
- MySQL系列:Docker安裝 MySQL提示錯誤:Access denied for user'root'@'localhost' (using password:yes)MySqlDockerlocalhost
- Navicat遠端連線MySQL 提示1045 - Access denied for user 'root'@'223.74.158.192'(using password:YES)MySql
- hive建立分割槽表報錯AccessControlException Permission denied: user=NONE, access=WRITE, inodeHiveExceptionNone
- load data infile ERROR 1045 (28000)Error
- ubuntu mysql Access denied for user root@localhostUbuntuMySqllocalhost
- 啟動報錯:Access denied for user 'root'@'localhost' (using password:YES)localhost
- laravel mysql批量提交報Access denied 錯誤LaravelMySql
- MySQL建立使用者報錯 ERROR 1396 (HY000): Operation CREATE USER failed for 'afei'@'%'MySqlErrorAI
- MySQL 5.7 建立使用者報錯 ERROR 1805 (HY000): Column count of mysql.user is wrongMySqlError
- SQLSTATE[HY000] [1045] Access denied for user ‘root‘@‘localhost‘ (using password: YES)”錯誤的隱藏解決辦法SQLlocalhost
- mac os x 安裝mysql遇到 Access denied for user ‘root‘@‘localhost‘ (using password: YES)的解決方法MacMySqllocalhost
- Permission denied:user=xxx,access=WRITE,inode=xxx
- OGG Director連線報錯Access denied
- Access denied for user ‘root‘@‘localhost‘問題的解決localhost
- 使用Mysql登入時,ERREORE 1045(28000) 解決方法MySql
- gitlab密碼更新後,使用git命令報錯remote: HTTP Basic: Access denied fatal: Authentication failed for ‘https:xxx‘Gitlab密碼REMHTTPAI
- nginx中報Access denied.Nginx
- java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: YES)JavaSQLExceptionlocalhost
- mysql報1045錯誤是什麼意思MySql
- golang原始碼安裝時fatal error: MSpanList_Insert錯誤Golang原始碼Error
- MySQL建立觸發器時報錯Error Code: 1064MySql觸發器Error
- 【ERROR】su user報'This account is currently not available'錯誤 for linuxErrorAILinux
- snipMate安裝後報錯
- 連網安裝mysql與原始碼安裝mysqlMySql原始碼
- MySQL error 錯 誤 碼MySqlError
- Centos5.5中安裝Mysql5.5過程分享CentOSMySql