16人参与 • 2025-04-24 • Mysql
(1)离线部署mysql可使用:
mysqladmin -u root password '123456'
(2)如是yum在线安装mysql可查看日志中的初始密码
grep -i password /var/log/mysqld.log
进入mysql的主配
vim /etc/my.cnf[mysqld]skip-grant-tables #添加此行,跳过密码验证,忽略权限表身份验证
重启mysql
systemctl restart mysqld
mysql show databases;describe mysql.user;
select host,user,authentication_string from mysql.user;
更改密码为‘123’
update mysql.user set authentication_string=password('123') where user='root';
刷新授权
flush privileges;quit
注释调跳过密码认证
vim /etc/my.cnf
mysql -uroot -p123
更改完成后在数据库里输入命令,如提示以下错误:
error 1820 (hy000): you must reset your password using alter user statement before executing this statement.
则执行
mysql> alter user root@localhost identified by '123';
测试:
mysql> show databases;
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
您想发表意见!!点此发布评论
版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。
发表评论