ERROR 1396 (HY000): Operation RENAME USER failed for ' root ' @ '% '

Source: Internet
Author: User

To avoid security risks in MySQL, rename the default root user.

Using the Rename user command to modify the root username failed,

Hint Error: 1396 (HY000): Operation RENAME USER failed for ' root ' @ '% '

Modified successfully using the User table under Update MySQL user.

mysql> use MySQL;

Database changed

Mysql> Select Host, user, password from user;

+-----------+------+-------------------------------------------+

| Host | user | password |

+-----------+------+-------------------------------------------+

| localhost | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |

| 127.0.0.1 | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |

| :: 1 | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |

+-----------+------+-------------------------------------------+

3 Rows in Set (0.00 sec)

mysql> Rename user root to admin;

ERROR 1396 (HY000): Operation RENAME USER failed for ' root ' @ '% '

However, it is no problem to rename a normal user with the same command.

mysql> Update user set user= ' admin ' where user= ' root ';

Query OK, 3 rows affected (0.09 sec)

Rows Matched:3 Changed:3 warnings:0

mysql> flush Privileges;

Query OK, 0 rows Affected (0.00 sec)

Mysql> Select Host, user, password from user;

+-----------+-------+-------------------------------------------+

| Host | user | password |

+-----------+-------+-------------------------------------------+

| localhost | admin | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |

| 127.0.0.1 | admin | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |

| :: 1 | admin | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |

+-----------+-------+-------------------------------------------+

3 Rows in Set (0.00 sec)

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.