zoukankan      html  css  js  c++  java
  • mysql修改root密码

    网上直接的 UPDATE user SET password=PASSWORD("new password") WHERE user='name'; 基本就是坑跌

    使用本文方法修改成功!

     

    方法一:

    (适用于管理员或者有全局权限的用户重设其它用户的密码)
    进入命令行模式
    mysql -u root mysql 
    mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='name';
      mysql> FLUSH PRIVILEGES;
      mysql> QUIT

    方法二:
    (应用同上,只是方法不同)
     mysql -u root mysql
      mysql> SET PASSWORD FOR name=PASSWORD('new password');
      mysql> QUIT 

    (以上两种方法我不常用,如果是管理员,我会用其它如phpmyadmin或者MYSQL-front 等工具来管理用户权限,比较直观又方便)

    最后必杀技:

    mysqladmin -u root "old password" "new password"

    解:以上有name的,请用你的用户名来替代.有new password请输入你想要设置的密码.

    提示错误:No Database Selected后如何修改

    C:\mysql\bin>mysql 

     -uroot
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 4 to server version: 4.0.15-nt

    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql> update user set password=password('root') where user='root';
    ERROR 1046: No Database Selected
    mysql> use mysql
    Database changed
    mysql> select host,user from user;
    +-----------+------+
    | host      | user |
    +-----------+------+
    | %         |      |
    | %         | root |
    | localhost |      |
    | localhost | root |
    +-----------+------+
    4 rows in set (0.02 sec)

    mysql> update user set password=password('root') where user='root';
    Query OK, 2 rows affected (0.00 sec)
    Rows matched: 2  Changed: 2  Warnings: 0

    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.02 sec)

    mysql> quit
    Bye

    C:\mysql\bin>mysql  -uroot
    ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

    C:\mysql\bin>mysql  -uroot -proot
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 6 to server version: 4.0.15-nt

    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql> quit
    Bye

  • 相关阅读:
    数据结构-二叉树--二叉搜索树
    Django之Model操作
    Django之Form组件
    Django之url(路由)配置
    Django框架之模板继承和静态文件配置
    Django框架之第三篇模板语法(重要!!!)
    Django ORM操作及进阶
    django 之 ORM操作多表联查总结
    人生苦短,我学python之python xml数据解析
    人生苦短,我学python之python re正则表达式
  • 原文地址:https://www.cnblogs.com/nafio/p/9137775.html
Copyright © 2011-2022 走看看