Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (55.6k points)

Can anyone tell me what is the default password of MySQL?

3 Answers

0 votes
by (119k points)

In MySQL, by default, the username will be root and there won’t be any password.

If you accidentally kept a password and forgot, here is how to reset the password:

Terminate the MySQL server and restart it with the –skip-grant-tables option.

sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &

After that, connect to the MySQL Server using the MySQL client:

 mysql -u root

After that, run this command to reload the grant tables:

FLUSH PRIVILEGES;

Now you can set a new password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

If you want to learn MySQL from top professionals, then register for this SQL Certification program by Intellipaat.

Also, watch this video on MySQL:

0 votes
by (37.3k points)

By default, there is no universal password in MySQL. Let's say that you have installed your MySQL. The username will be ‘root’ but there won’t be any default password. You can just leave the password place empty and press enter. 

If you want to change the password in MySQL, you can use the below query.

UPDATE mysql.user SET user='newusername',

 password=PASSWORD('newpassword') WHERE user='root';

 FLUSH PRIVILEGES;

0 votes
ago by (2.8k points)
In MySQL, the default username will be root, and typically, it won't have a password set.

 If you've set a password, but cannot remember it, here's how you can reset that:

 First of all, stop the MySQL server and start it again with the option –skip-grant-tables.

 Use the command: sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking & Now, connect to the MySQL Server via the MySQL client:

 mysql -u root

Then run the following command to update the grant tables:

 FLUSH PRIVILEGES;

You can now enter whatever new password you want:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

Related questions

0 votes
1 answer
asked Dec 22, 2020 in SQL by Appu (6.1k points)
0 votes
2 answers
asked Jun 26, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...