网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 生活知识 知识问答

centos mysql设置密码

时间:2026-02-16 00:30:37

1、方法一:

grep 'temporary password' /var/log/mysqld.log

centos mysql设置密码

2、运行后会得到一个密码,这里我的centos7.4下没有反应,故尝试第二种方法

centos mysql设置密码

3、方法二:

该方法先修改mysql配置文件使其可以无密码登录,让后修改密码,之后便复原配置文件

修改/etc/my.cnf 

vim /etc/my.cnf

centos mysql设置密码

4、配置文件添加skip-grant-tables 

保存后重启mysql

systemctl restart mysql

centos mysql设置密码

5、即可免密登录,命令行输入mysql直接登录

选择mysql数据库,输入下列命令重置密码,'new-password'即为所设置密码

centos mysql设置密码

6、修改完成后输入exit退出,重新回到/etc/my.cnf该文件删除之前添加语句即可完成

centos mysql设置密码

© 2026 智德知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com