Home > Database > Mysql Tutorial > mysql ERROR 1045_MySQL

mysql ERROR 1045_MySQL

WBOY
Release: 2016-06-01 13:10:30
Original
1018 people have browsed it

C:/Program Files/MySQL/MySQL Server 5.0/bin> mysql -u root -p

Enter password:

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

 

编辑mysql配置文件my.ini(不知道在哪请搜索),在[mysqld]这个条目下加入

  skip-grant-tables

保存退出后重启mysql

1.点击“开始”->“运行”(快捷键Win+R)。

  2.启动:输入 net stop mysql

  3.停止:输入 net start mysql


这时候在cmd里面输入mysql -u root -p就可以不用密码登录了,出现password:的时候直接回车可以进入,不会出现ERROR 1045 (28000),但很多操作都会受限制,因为我们不能grant(没有权限)。按下面的流程走(红色部分为输入部分,粉红色的是执行后显示的代码不用输入):

1.进入mysql数据库:

mysql> use mysql;

Database changed

2.给root用户设置新密码,蓝色部分自己输入:

mysql> update user set password=password("新密码") where user="root";

Query OK, 1 rows affected (0.01 sec)

Rows matched: 1 Changed: 1 Warnings: 0

3.刷新数据库

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

4.退出mysql:

mysql> quit

Bye

改好之后,再修改一下my.ini这个文件,把我们刚才加入的"skip-grant-tables"这行删除,保存退出再重启mysql就可以了。



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template