linux上mysql忘记密码

一、更改配置文件,跳过密码登录
    vim /etc/my.cnf
    [mysql]
    skip-grant-tables

    重启mysql

二、空密码进入数据库,更改用户密码
    不用密码直接进入数据库,再更改用户密码
    use mysql;update user set password=password('123456') where user='root' and host='localhost';flush privileges;

三、注释跳过密码
    vim /etc/my.cnf
    [mysql]
    #skip-grant-tables
    
    重启mysql

猜你喜欢

转载自blog.csdn.net/zzhlinux911218/article/details/85118133
今日推荐