zoukankan      html  css  js  c++  java
  • Linux下修改Mysql密码的三种方式

    一、拥有原来的myql的root的密码

    方法一: 

    在mysql系统外,使用mysqladmin

    mysqladmin -u root -p password "test123"

    方法二:

    通过登录mysql系统

    mysql -uroot -p
    Enter password: 【输入原来的密码】
    mysql>use mysql;
    mysql> update user set password=passworD("test") where user='root';
    mysql> exit; 

    注意:如果Mysql的版本是5.7及以上的话update语句更换如下:

    mysql> update user set authentication_string=passworD("test") where user='root';

    二、忘记原来的myql的root的密码

    方法三:

    首先拿到操作系统的root权限,然后kill掉Mysql服务或者手动stop掉,这里我推荐使用手动stop;

    service mysql stop

    然后执行

    mysqld_safe --skip-grant-tables &

    & 表示在后台运行,不再后台运行的话,就再打开一个终端吧。

    接着登陆MySQL修改密码

    mysql
    mysql> use mysql;
    mysql> UPDATE user SET password=password("test123") WHERE user='root';   
    mysql> exit; 

    注意:如果Mysql的版本是5.7及以上的话update语句如下:

    mysql> update user set authentication_string=passworD("test") where user='root';

    来源:https://www.cnblogs.com/surplus/p/11642773.html

    抄一遍主要是因为之前有的收藏会被删,没法子

  • 相关阅读:
    JS-07 (js的面向对象编程)
    AI SiameseFC
    phpstorm调试
    Php 编译扩展
    canvas
    AI FCN
    AI WebGL
    Python flask
    JIT 即时编译
    小程序
  • 原文地址:https://www.cnblogs.com/init-007/p/13129656.html
Copyright © 2011-2022 走看看