找不到原创了,百度了一下,这个比较像。感谢原创的贡献。
vi /etc/my.cnf
在配置文件中加入
skip-grant-tables
mysqld_safe --skip-grant-tables&
最佳答案
MySQL安装时默认的用户是root,这里的root是指数据库的用户,root密码一般在初始化MySQL时存放在你的日志文件中,日志文件的存放路径可以通过my.cnf文件进行自定义。
使用如下方法即可解决,本人已验证可行。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #1.停止mysql数据库 /etc/init.d/mysqld stop #2.执行如下命令 mysqld_safe --user=mysql --skip-grant-tables --skip-networking & #3.使用root登录mysql数据库 mysql -u root mysql #4.更新root密码 mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root'; #最新版MySQL请采用如下SQL: mysql> UPDATE user SET authentication_string=PASSWORD('newpassword') where USER='root'; href="mailto:leisong@cdb-leasing.com/pwd@321" leisong@cdb-leasing.com/pwdxxxx #5.刷新权限 mysql> FLUSH PRIVILEGES; #6.退出mysql mysql> quit #7.重启mysql /etc/init.d/mysqld restart #8.使用root用户重新登录mysql mysql -uroot -p Enter password: <输入新设的密码newpassword> |
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)