• 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

  • 相关阅读:
    第6周编程题:零基础学Java
    帆软报表软件学习计划
    北大软件工程——第八周:面向对象设计2
    hdu1264 Counting Squares
    hdu1264 Counting Squares
    poj1151 Atlantis(线段树+扫描线)
    poj1151 Atlantis(线段树+扫描线)
    bzoj4653 [Noi2016]区间
    bzoj4653 [Noi2016]区间
    Tyvj1043
  • 原文地址:https://www.cnblogs.com/nafio/p/9137775.html
Copyright © 2020-2023  润新知