美文网首页Spring boot
mac下mysql忘记了密码怎么办

mac下mysql忘记了密码怎么办

作者: 三也视界 | 来源:发表于2020-11-27 09:22 被阅读0次
    1. 关闭mysql服务
      sudo /usr/local/mysql/support-files/mysql.server stop 或者系统偏好里有个 MySQL 里关闭

    2.来到mysql目录下
    cd /usr/local/mysql/bin

    3.得到权限
    sudo su

    4.重启mysql服务
    ./mysqld_safe --skip-grant-tables & 或者在系统编号中开启

    5.重开终端
    mysql -uroot -p (提示输入密码时随便输入即可

    1. 拿到权限(可以修改密码)
      flush privileges;

    7.修改密码
    set password for 'root'@'localhost'=password('新密码');

    set password for 'root'@'localhost'=password('新密码');

    1. 关闭mysql服务
      sudo /usr/local/mysql/support-files/mysql.server stop 或者系统偏好里有个 MySQL 里关闭

    2.来到mysql目录下
    cd /usr/local/mysql/bin

    3.得到权限
    sudo su

    4.重启mysql服务
    ./mysqld_safe --skip-grant-tables & 或者在系统编号中开启

    5.重开终端
    mysql -uroot -p (提示输入密码时随便输入即可

    1. 拿到权限(可以修改密码)
      flush privileges;

    7.修改密码
    set password for 'root'@'localhost'=password('新密码');

    set password for 'root'@'localhost'=password('新密码');

    1. 关闭mysql服务
      sudo /usr/local/mysql/support-files/mysql.server stop 或者系统偏好里有个 MySQL 里关闭

    2.来到mysql目录下
    cd /usr/local/mysql/bin

    3.得到权限
    sudo su

    4.重启mysql服务
    ./mysqld_safe --skip-grant-tables & 或者在系统编号中开启

    5.重开终端
    mysql -uroot -p (提示输入密码时随便输入即可

    1. 拿到权限(可以修改密码)
      flush privileges;

    7.修改密码
    set password for 'root'@'localhost'=password('新密码');

    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'password(’root‘)' at line 1

    解决:mysql8 要求先建用户,后授权

    新增用户、授权

    mysql> create user root@'%' identified by 'root';

    mysql> GRANT all on . TO root@'%';

    mysql> flush privileges;

    取消授权

    msyql> revoke all ON . FROM root@'%';

    相关文章

      网友评论

        本文标题:mac下mysql忘记了密码怎么办

        本文链接:https://www.haomeiwen.com/subject/updriktx.html