How MySQL changes password and user name

Source: Internet
Author: User

How MySQL changes password and user name
  • Change password (old version):

    mysql -u root -p  Enter password:***  mysql>use mysql;      --选择数据库-- Database changed   mysql> UPDATE user SET password=PASSWORD("新密码") WHERE user=‘你的用户名‘;  mysql> FLUSH PRIVILEGES;  mysql> quit;  
  • The newly installed MySQL5.7, the login prompt password error, when the installation did not change the password, and later through the password-free way to change the password, input

    update mysql.user  set password=password(‘root‘) where user=‘root‘;

    Tips

    ERROR 1054 (42S22): Unknown column ‘password‘ in ‘field list‘,

    The original MySQL database has no password This field, password field changed to Authentication_string

  • So the change statement is replaced with

    update mysql.user set authentication_string=password(‘root‘) where user=‘root‘;
  • change user name:

    mysql -u root -p  Enter password:***  mysql> use mysql;          --选择数据库--Database changed  mysql> update user set user="新用户名" where user="root";    --将用户名为root的改为新用户名--  mysql> flush privileges;    --刷新权限--  mysql> exit

How MySQL changes password and user name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.