中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

mysql出現1045錯誤怎么辦

發布時間:2021-11-06 11:23:58 來源:億速云 閱讀:263 作者:小新 欄目:MySQL數據庫

這篇文章給大家分享的是有關mysql出現1045錯誤怎么辦的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

--mysql5.6,安裝好后進行登錄出現
[root@mytest_db usr]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

提示密碼問題,再用命令修改,也會出現以下錯誤
[root@mytest_db usr]# mysqladmin -u root password 'petrel'
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

這個時候需要用這種方法進行處理
--重啟mysql服務,采用mysqld_safe的方式進行
[root@mytest_db usr]# service mysql stop
Shutting down MySQL...[  OK  ]
[root@mytest_db usr]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 5043
啟動后,就可以直接不用密碼直接進入了,這個時候重新設置密碼
[root@mytest_db usr]# mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set Password=PASSWORD('petrel') where user = 'root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@mytest_db usr]# service mysql restart
這個時候,再進行登錄就沒問題了

[root@mytest_db data]# mysql -uroot -ppetrel
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.19

Copyright (c) 2000, 2014, 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> use mysql;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> grant all privileges  on *.* to root@'localhost'   identified   by 'petrel';
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> set PASSWORD=PASSWORD('petrel');
Query OK, 0 rows affected (0.00 sec)

--出現mysql.user表里面用戶為空時出現
ERROR 1045 (28000): Access denied for user
這個時候可以進行如下處理
刪除這些為空的用戶或者更新為其他用戶名
刪除user.user中值為NULL的,或更新NULL為其它值等
mysql> delete from user where user is NULL
Query OK, 1 rows affected (0.00 sec)
或者更新為其它值
mysql> update user set user='mytest' where user is NULL
Query OK, 1 rows affected (0.00 sec)

--如果mysql.user表里面沒有可以訪問的用戶,也會出現
MYSQL ERROR 1045 (28000): Access denied for user (using password: YES)
這個時候,我們就要采用如下步驟進行
[root@mytest_db usr]# service mysql stop
Shutting down MySQL...[  OK  ]
[root@mytest_db usr]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[root@mytest_db usr]# mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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> select * from user;
發現沒有用戶
mysql> INSERT INTO user(host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost', 'username', PASSWORD(‘yourpassword'), 'Y', 'Y','Y');
Query OK, 1 row affected, 3 warnings (0.00 sec)

感謝各位的閱讀!關于“mysql出現1045錯誤怎么辦”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

炎陵县| 芦山县| 顺昌县| 萨迦县| 望谟县| 洛扎县| 如东县| 庆城县| 桂阳县| 锡林郭勒盟| 南岸区| 七台河市| 措勤县| 漳平市| 贵州省| 兰溪市| 青川县| 陵川县| 舒兰市| 潜江市| 泽普县| 花莲县| 金平| 青河县| 安新县| 集贤县| 太原市| 五台县| 娱乐| 宜兰县| 营山县| 从化市| 穆棱市| 迭部县| 夏津县| 普兰店市| 葵青区| 宾阳县| 河曲县| 三亚市| 富阳市|