您的当前位置:首页正文

MySQL error 1045

2024-12-12 来源:个人技术集锦
[root@localhost ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

尝试1: 添加一个初始密码

[root@localhost ~]# mysqladmin -hlocalhost -uroot password"123"
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

尝试2: 修改mysql的配置文件

[root@localhost ~]# vim /etc/my.cnf
[mysqld]
skip-grant-table        //这句表达的意思呢是“跳过授权表,即无密码直接进入啦”

重启服务

[root@localhost ~]# service mysqld restart
停止 mysqld[OK]
启动 mysqld[OK]

再次进入

[root@localhost ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.95 Source distribution

Copyright (c) 2000, 2011, 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>
显示全文