Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change USERNAME And PASSWORD of MySQL? [closed]

Tags:

I have installed MySQL Server 5.0 on my machine (Windows-7 OS).

My existing USERNAME And PASSWORD for MySQL is root. I want to change both USERNAME And PASSWORD.

Many people have asked this question before but none was useful for me. Can anybody
tell me HOW and from WHERE can I change it?

like image 431
Dnyanesh M Avatar asked Dec 13 '13 09:12

Dnyanesh M


People also ask

How do I find MySQL userName and password?

So for example, to show MySQL users' username, password and host, we'll modify the sql query to accordingly as such: mysql> select user, password, host from mysql. user; The above sql query will present you with a list of users and their respective user name, password and database host.

How can I change my userName in MySQL?

You can use the RENAME USER statement to rename multiple users by comma separating the user name values. For example: RENAME USER 'smithj'@'localhost' TO 'jane'@'localhost', 'andersonk'@'localhost' TO 'kyle'@'localhost'; This RENAME USER example would rename two users in MySQL.


2 Answers

Just execute this query from mysql console:

 UPDATE mysql.user SET user='newusername',  password=PASSWORD('newpassword') WHERE user='root';  FLUSH PRIVILEGES; 
like image 84
Ghigo Avatar answered Sep 23 '22 01:09

Ghigo


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

like image 42
Amarnath Balasubramanian Avatar answered Sep 24 '22 01:09

Amarnath Balasubramanian