先关闭mysql进程,方法就不用我说了哈!
遇到错误:(#1045 access denied for user ‘root’@’localhost’ using password yes)时,可以使用此方法!
到WINDOWS的命令行了(‘DOS’ 下),切换到你的MySQL bin目录下。 比如我的是 D:\wamp\bin\mysql\mysql5.5.8\bin
然后敲下面的粗体的命令。注意你的my.ini位置。
D:\wamp\bin\mysql\mysql5.5.8\bin>mysqld –defaults-file=”D:\wamp\bin\mysql\mysql5.5.8\my.ini” –console –skip-grant-tables
090515 22:06:09 [Warning] The syntax ‘–log’ is deprecated and will be removed i
n MySQL 7.0. Please use ‘–general_log’/’–general_log_file’ instead.
090515 22:06:09 [Warning] The syntax ‘–log_slow_queries’ is deprecated and will
be removed in MySQL 7.0. Please use ‘–slow_query_log’/’–slow_query_log_file’
instead.
090515 22:06:09 [Warning] The syntax ‘–log’ is deprecated and will be removed i
n MySQL 7.0. Please use ‘–general_log’/’–general_log_file’ instead.
090515 22:06:09 [Warning] The syntax ‘–log_slow_queries’ is deprecated and will
be removed in MySQL 7.0. Please use ‘–slow_query_log’/’–slow_query_log_file’
instead.
090515 22:06:09 [ERROR] The update log is no longer supported by MySQL in versio
n 5.0 and above. It is replaced by the binary log. Now starting MySQL with –log
-bin=” instead.
090515 22:06:09 InnoDB: Started; log sequence number 0 324221
090515 22:06:09 [Note] mysqld: ready for connections.
Version: ‘5.1.33-community-log’ socket: ” port: 3306 MySQL Community Server
(GPL)
看到这个结果就说明MySQL已经起来了。
再开一个DOS窗口,同样切到mysql bin目录下,
D:\wamp\bin\mysql\mysql5.5.8\bin>mysql -uroot mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.33-community-log MySQL Community Server (GPL)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql>
# /etc/init.d/mysql stop
# mysqld_safe –user=mysql –skip-grant-tables –skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>
然后
D:\wamp\bin\mysql\mysql5.5.8\bin>mysqladmin shutdown
之后正常重启MySQL服务就行了。
这是我今天上午安装wamp后遇到的问题,我设置了root密码之后用的里面自带的什么mysql4.0加密,结果我没记住那个加密后的密码,然后就只能通过修改密码的方式了,网上总结了大概3种方法,这种是其中的一种,但是很多人没有把如何从dos下调到mysql状态下的的步骤写出来,所以很多新手可能不知道如何去操作,我就是这样一个新手哈。
转载请注明:Rockyxia Web技术博客 » 修改mysql的root用户密码
感谢阅读,如果您发现文章中有表述不准确,欢迎提出来,也欢迎交流相关问题,你可以去这里进行一对一问答交流。