  

|
[技术文章] CentOS中重置MySQL数据库root密码的方法
连接数据库若出现错误1045,为密码错误,需要重置密码:
停止服务:/etc/init.d/mysqld stop
跳过验证:/usr/bin/mysqld_safe--skip-grant-tables >/dev/null 2>&1 &
若无效,编辑/etc/my.cnf
[mysqld]
skip_grant_tables
重启服务:service mysqld restart
修改密码:mysql -u root mysql (登录mysql)
密码:空
use mysql
update user set password=password('新密码') where user='root';(修改密码)
mysql>flush privileges; ( 刷新MySQL权限相关的表)
mysql>exit (退出MySQL)
重启服务:
killall mysqld (杀死mysql进程)
/etc/init.d/mysql start (启动mysql服务) |
|