当数据库root密码忘记或者安装数据库时默认密码太繁琐。推荐使用如下方法
第一步:找到mysql的配置文件 my.cnf ,mysqld添加 代码 --skip-grant-tables
--skip-grant-tables
第二步:登录MySQL
mysql -uroot -p
第三步:执行一下语句;update mysql.user set authentication_string='1234' where user='root' and host='%';
update mysql.user set authentication_string='1234' where user='root' and host='%';
第四步:刷新 flush privileges
flush privileges
最后:重启服务 service mysqld restart
service mysqld restart搞定
分享时为了更好的节约大家时间。爱分享。爱交流



