初始化密码
安装完mysql后,默认root没有密码
#service mysqld start
#/usr/bin/mysqladmin -u root password “newpasswd”
重置密码
如果忘记了Mysql的root密码,那就只能重置了。
首先关闭mysql服务
rhel7
#systemctl stop mysqld
rhel6
#service mysqld stop
然后安全模式启动
#mysqld_safe –skip-grant-tables &
#mysql
>use mysql
>update user set password=password(“newpasswd”) where user=’root’;
>update user set authentication_string=password(“newpasswd”) where user=’root’; #mysql 7.8
>flush privileges;
之后操作时还报错:You must SET PASSWORD before executing this statement解决
mysql> SET PASSWORD = PASSWORD(‘newpasswd’);
在重新设置一次密码