How to change USERNAME And PASSWORD of MySQL?

Instructions

  1. Click the Windows "Start" button and type "cmd" in the search text box. Press Enter to open the Windows command line.

  2. Type "mysql" and press Enter to start the MySQL command line utility. Using the MySQL command line, you can update the tables on the database.

  3. Type the following SQL code to update the root user:
    UPDATE mysql.user SET user='newuser' WHERE User = 'root';
    Change newuser with the value you want to use in place of root

  4. Type the following SQL code to change the default user's password:
    UPDATE mysql.user SET authentication_string = password('pass') WHERE User = 'newuser';
    Replace pass with the new password, and replace newuser with the name of the user you set up in the previous step.

Read more

To change UserName and Password from mysql console


There are special MySQL commands:

  1. RENAME USER
  2. SET PASSWORD

USE THIS CMD IN MYSQL CONSOLE OR CMD

STEP 1: mysql> use mysql;

STEP 2: CREATE USER 'username'@'localhost' IDENTIFIED BY 'mypass';


Just execute this query from mysql console:

 UPDATE mysql.user SET user='newusername',
 password=PASSWORD('newpassword') WHERE user='root';
 FLUSH PRIVILEGES;

Tags:

Mysql