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 userError
- Mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- mysql ERROR 1045 (28000): Access denied for user解決方法MySqlError
- MySQL 登入資料庫報錯'ERROR 1045 (28000): Access denied for user'..'@'localhost''MySql資料庫Errorlocalhost
- ERROR 1045 (28000): Access denied for user 'root'@'localhost'Errorlocalhost
- Error 1045(28000) Access Denied for user 'root'@'localhost'Errorlocalhost
- 報錯”ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)”Errorlocalhost
- 解決Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- rhel4 mysql5.1登陸ERROR 1045 (28000): Access denied for userMySqlError
- 登入mysql報ERROR 1045 (28000): Access denied 解決方法MySqlError
- linux安裝MySQL出現ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)LinuxMySqlErrorlocalhost
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:YES)Errorlocalhost
- MySQL 8.0.13 密碼問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)MySql密碼Errorlocalhost
- ERROR 1045 (28000): Access denied for user 'root'@'127.0.0.1' (using password: YES)Error127.0.0.1
- Linux錯誤 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)LinuxErrorlocalhost
- ERROR 1045 (28000): ProxySQL Error: 報錯ErrorSQL
- ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)Errorlocalhost
- MySQL使用普通使用者訪問返回ERROR 1698 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- MySQL 5.5 原始碼安裝報錯"[ERROR] Can't start server"MySql原始碼ErrorServer
- mysql 1045, "Access denied for user 'root'@'localhost' (using password: NO)"MySqllocalhost
- Ubuntu18.04:mysql:ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘UbuntuMySqlErrorlocalhost
- Mysql資料庫報ERROR 1045 (28000)報錯及MySQL忘記密碼找回MySql資料庫Error密碼
- 【MySQL】---1045-Access denied for user 'root'@'localhost'(using password :YES)MySqllocalhost
- Access denied for user 'default'@'%' to database 'shop'報錯Database
- vue專案中連線MySQL時,報錯ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password:YES)VueMySqlErrorlocalhost
- #1045 - Access denied for user 'root'@'localhost' (using password: NO)localhost
- 一看便知linux下mysql報錯ERROR 1044: Access denied for user: '@localhost' to database 'mysql'LinuxMySqlErrorlocalhostDatabase
- mysql登入報錯提示:ERROR 1045 (28000)的解決方法MySqlError
- MySQL系列:Docker安裝 MySQL提示錯誤:Access denied for user'root'@'localhost' (using password:yes)MySqlDockerlocalhost
- MySQL 5.5原始碼安裝時啟動資料庫報錯"Table 'mysql.user' doesn't exist??"MySql原始碼資料庫
- MYSQL解決error: 'Access denied for user 'root'@'localhost' (using password:MySqlErrorlocalhost
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'ErrorlocalhostDatabaseMySql
- MySQL報錯 Error_code: 1045MySqlError
- laravel mysql批量提交報Access denied 錯誤LaravelMySql
- ubuntu mysql Access denied for user root@localhostUbuntuMySqllocalhost
- 解決mysql“Access denied for user 'root'@'localhost'”MySqllocalhost
- MySQL 5.5 原始碼安裝流程MySql原始碼
- 啟動報錯:Access denied for user 'root'@'localhost' (using password:YES)localhost