mysql 1045 1044等综合问题的解决方法讲解
程序员文章站
2022-04-15 13:06:59
如果某天发现自己登陆不上mysql,又恰巧记不得密码,那只能通过本地重新修改mysql.user里面的密码。
首先
$ sudo service mysqld stop /...
如果某天发现自己登陆不上mysql,又恰巧记不得密码,那只能通过本地重新修改mysql.user里面的密码。
首先
$ sudo service mysqld stop //确认mysqld和免安装的mysqld都关闭 $ sudo mysqld_safe --skip-grant-table & //进入本地安全模式
到这里后mysql可以直接用root登陆进去不需要密码,接着
mysql>use mysql mysql>SELECT host,user,password,Grant_priv,Super_priv FROM mysql.user; +--------------+---------+-------------------------------------------+------------+------------+ | host | user | password | Grant_priv | Super_priv | +--------------+---------+-------------------------------------------+------------+------------+ | 192.168.28.% | Looft | *FED29C14B2E900D70B11B1F1B370F953BA51A6A0 | N | Y | | 192.168.28.% | live | *FED29C14B2E900D70B11B1F1B370F953BA51A6A0 | N | Y | | 192.168.28.% | root | *FED29C14B2E900D70B11B1F1B370F953BA51A6A0 | Y | Y | | localhost | ranger | wtfwtfwtf | N | N | | localhost | root | 0 | Y | Y | | % | root | *FED29C14B2E900D70B11B1F1B370F953BA51A6A0 | N | Y | | 127.0.0.1 | root | *FED29C14B2E900D70B11B1F1B370F953BA51A6A0 | Y | Y | | % | ranger | *84BB87F6BF7F61703B24CE1C9AA9C0E3F2286900 | N | Y | +--------------+---------+-------------------------------------------+------------+------------+
这里看到ranger@localhost密码有问题,没有权限,没有通过password函数进行加密,跟其他的不一样。于是进行update更改密码并加密
mysql>UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y',Password=password('wtfwtfwtf') WHERE User='ranger' and host='localhost'; mysql>flush privileges;
搞定之后记得关闭mysqld_safe,并开启mysqld进程。
$ sudo mysqladmin -uroot -p***** shutdown $ sudo service mysqld start $ mysql -uranger -pwtfwtfwtf Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 20 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, 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>
测试后ok
新加入规则也很简单
mysql>insert into mysql.user(Host,User,Password) values("127.0.0.1","ranger",Password=password('wtfwtfwtf'));
上一篇: 游戏之中雷人事儿
下一篇: 取得服务器上用户组列表的脚本之asp版
推荐阅读
-
mysql ERROR 1045 (28000)问题的解决方法
-
ubuntu系统中Mysql ERROR 1045 (28000): Access denied for user root@ localhost问题的解决方法
-
实例讲解MySQL数据库中文问题的解决方法_MySQL
-
mysql ERROR 1045 (28000)问题的解决方法
-
ubuntu系统中Mysql ERROR 1045 (28000)报错问题的解决方法的图文详解
-
mysql 1045 1044等综合问题的解决方法讲解
-
ubuntu系统中Mysql ERROR 1045 (28000): Access denied for user root@ localhost问题的解决方法
-
ubuntu系统中Mysql ERROR 1045 (28000)报错问题的解决方法的图文详解