操作系统:Linux centos7
数据库:mysql5.7
mysqladmin –u root –p password “新密码” 回车后要求输入旧密码
Update mysql.user set password=password(‘新密码’) where user=’root’; flush privileges;
grant all on *.* to root@’localhost’ identified by ‘新密码’; grant all on *.* to root@’%’ identified by ‘新密码’;
service mysqld stop(要先将mysqld添加为系统服务)
/usr/local/mysql/bin/mysqld_safe --skip-grant-table &
或
直接在配置文件中添加一行,然后重启服务,在执行第3步
[root@VM_0_10_centos ~]# cat /etc/my.cnf [mysqld] #添加跳过密码验证 #skip-grant-tables
[root@VM_0_10_centos ~]# service mysqld restart
#mysql -u root Mysql> Update mysql.user set password=password(‘新密码’) where user=’root’; Mysql> flush privileges;