日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql 1044_mysql重置密码和mysql error 1044(42000)错误

發布時間:2023/12/20 数据库 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 1044_mysql重置密码和mysql error 1044(42000)错误 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

#mysql錯誤:(密碼不正確,需要重置密碼)

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

#編輯配置文件

[root@m1 mysql]# vi /roobo/server/mysql/my.cnf

[mysqld]

skip-grant-tables

#修改完后重啟服務

[root@m1 mysql]# /etc/init.d/mysqld restart

#登錄數據庫

[root@m1 mysql]# mysql

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.24-log Source distribution

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>?use?mysql;

mysql>?update?user?set?password=password("你的新密碼")?where?user="root";

mysql>?flush?privileges;

mysql>?quit

#再把vi my.cnf 配置文件中下面參數刪除。

[mysqld]

skip-grant-tables

#修改完后重啟服務

[root@m1 mysql]# /etc/init.d/mysqld restart

#再用設置的密碼登錄

mysql -uroot -p

passwd:******

mysql error 1044(42000)錯誤

[root@m1 ~]# mysql -uroot -p

Enter password:

ERROR 1049 (42000): Unknown database '127.0.0.1'

[root@m1 ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 18

Server version: 5.6.24-log Source distribution

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> grant all on work.* to work@'192.168.1.4' identified by 'juan3652014';

ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'work'

原因:? 授權需要WITH GRANT OPTION 才能授權,否則會報。

mysql> show grants for root@'localhost';

+----------------------------------------------------------------------------------------------------------------------+

| Grants for root@localhost |

+----------------------------------------------------------------------------------------------------------------------+

| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*F109C974766912D490ECD7E3C8754542FC773A49' |

| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION

+----------------------------------------------------------------------------------------------------------------------+

2 rows in set (0.00 sec)

解決方法:

#登錄mysql

mysql -uroot -p -h 127.0.0.1

mysql> use mysql

Database changed

mysql> select user,host from user;

+--------+-------------+

| user | host |

+--------+-------------+

| root | 127.0.0.1 |

| rep | 192.168.1.% |

| work | 192.168.1.4 |

| root | localhost |

| zabbix | localhost |

+--------+-------------+

5 rows in set (0.00 sec)

#授權成功

grant all on work.* to work@'192.168.1.4' identified by 'juan3652014';

flush privileges;

如上所示,root@localhost賬號沒有WITH GRANT OPTION選項,關于WITH GRANT OPTION選項,如果想讓授權的用戶,也可以將這些權限授予給其他用戶,需要選項“WITH GRANT OPTION“。也就是說有這個選項就可以將權限傳遞給第三方。這也是上面給其它用后授權報錯的原因,如果以root@127.0.0.1登錄(此賬號擁有WITHGRANT OPTION選項),創建用戶并授權就不會有這個錯誤。

總結

以上是生活随笔為你收集整理的mysql 1044_mysql重置密码和mysql error 1044(42000)错误的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。