ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
当我输入root登录输入密码就会出现这种错误,不输入密码就可以登录,不输入密码里面只有information_scheme和test两个库。
然后我使用安全登录,这里注意要先关闭mysql服务
| #关闭mysql |
| [root@localhost bin]# systemctl stop mariadb |
| #安全模式启动 |
| [root@localhost bin]# mysqld_safe --skip-grant-tables & |
| mysql |
| MariaDB [(none)]> show databases; |
| +--------------------+ |
| | Database | |
| +--------------------+ |
| | information_schema | |
| | mysql | |
| | performance_schema | |
| | test | |
| +--------------------+ |
| 4 rows in set (0.00 sec) |
| MariaDB [(none)]> 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 |
| #我这里localhost没有密码,必须要设置密码 |
| MariaDB [mysql]> select Host,User,Password from user; |
| +-----------------------+------+-------------------------------------------+ |
| | Host | User | Password | |
| +-----------------------+------+-------------------------------------------+ |
| | % | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | |
| | localhost.localdomain | root | | |
| | 127.0.0.1 | root | | |
| | ::1 | root | | |
| | localhost | root | | |
| | localhost.localdomain | | | |
| +-----------------------+------+-------------------------------------------+ |
| 6 rows in set (0.01 sec) |
| MariaDB [mysql]> update user set Password='root' where Host='localhost'; |
| Query OK, 1 row affected (0.00 sec) |
| Rows matched: 1 Changed: 1 Warnings: 0 |
| MariaDB [mysql]> select Host,User,Password from user; |
| +-----------------------+------+-------------------------------------------+ |
| | Host | User | Password | |
| +-----------------------+------+-------------------------------------------+ |
| | % | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | |
| | localhost.localdomain | root | | |
| | 127.0.0.1 | root | | |
| | ::1 | root | | |
| | localhost | root | root | |
| | localhost.localdomain | | | |
| +-----------------------+------+-------------------------------------------+ |
| 6 rows in set (0.00 sec) |
弄完之后就可以使用root登录了
本文作者:xiaoovo
本文链接:https://www.cnblogs.com/xiaoovo/p/17054036.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步