标签:tables 5.7 skip 密码 mysqld user 版本 mysql root
mysql8.0版本如何修改密码
第一步:
在mysql的配置文件中/etc/my.cnf 中 [mysqld] 下加入skip-grant-tables这条命令
vim /etc/my.cnf
[mysqld]
skip-grant-tables
第二步:
重启mysqld服务
service mysqld restart
第三步:
直接进入mysql
mysql -uroot
use mysql
update user set authentication_string='' where user='root';
exit
update user set authentication_string=’’ where user=‘root’;
使用此条命令清除密码为空
第四步:
进入/etc/my.cnf 将skip-grant-tables 注释 重启服务
因为此时将skip-grant-tables注释掉的话修改密码会报错:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
所以我们需要执行:
vim /etc/my.cnf
[mysqld]
#skip-gant-tables
service mysqld restart
第五步:
直接执行进入mysql 执行命令
mysql -uroot
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';
必须使用这个命令
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘你的密码’;
mysql 8.0中无法使用
1.update mysql.user set authentication_string=password(“123”) where user=‘root’;
2.mysql -uroot -p123.com -e “use mysql;update user set authentication_string=password(‘456’) where user=‘root’;”
标签:tables,5.7,skip,密码,mysqld,user,版本,mysql,root 来源: https://blog.csdn.net/m0_55724788/article/details/121939895
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。