linux--mysql改密码

61 阅读1分钟

linux安装的mysql忘记密码改密码


运行命令

ps -ef | grep -i mysql

在这里插入图片描述

关闭运行命令

service mysqld stop

在这里插入图片描述

修改mysql的配置文件my.conf

打开ftp文件/etc 在文件的[mysqld]标签下添加一句:skip-grant-tables 在这里插入图片描述

保存后启动数据库service mysqld start

进入到数据库mysql -u root

use mysql

继续

update mysql.user set authentication_string=password('root_password') where user='root';    
root_password替换成你想要的密码

然后再把之前添加在my.cnf skip-grant-tablesf语句删除 quit退出 mysql -u root 就能登录了