6

My initial installation for the MySQL had no password for root. I assigned a password for root and everything worked fine. Due to some reason (don't ask why) I had to revert back to the original settings where root didn't have any password.

I changed the root password to '' (empty string). The problem now is that MySQL doesn't run with 'mysql -uroot', it expects a password. On running 'mysql -uroot -p' and hitting enter on the password prompt gets me into the db, but is not same as the default setting.

Is there any other flag/setting that I am missing to set/unset which tells mysql to not expect a password?

Thanks

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
Gaurav
  • 486
  • 1
  • 3
  • 5
  • Paul mentioned a great idea. However, that is not really what I am looking for. There has to be some setting somewhere as a default instalation that tells root to not use password at all. – Gaurav Oct 16 '08 at 00:32
  • Please follow the steps included http://achala11.blogspot.com/ to reset the password for ubuntu –  Jan 24 '12 at 18:48

2 Answers2

11

How to Reset MySQL root password:

To reset it, see How to Reset the Root Password in the MySQL manual.

How to run MySQL without password controlled access

To run MySQL with the password controls disabled, check out the --skip-grant-tables option.

How to avoid typing credentials on the command line

If you simply want to avoid having to type the password on the mysql command line, create a file called .my.cnf (note leading period on that filename!) in your home directory. In your case, for the root user, probably /root

Add the following entries to the file

[client]
host=localhost
user     = root
password = mypassword
database = mydatabase

You'd typically chmod 600 this file so that only you can see it, and MySQL will ignore a .my.cnf which is world writable anyway.

See the manual page Using Option Files for more information

Paul Dixon
  • 295,876
  • 54
  • 310
  • 348
  • Paul - Thanks for the answer. Is there a way to --skip-grant-tables for a particular user (root in this case). After reading the documentation I understand that it is a server level setting. – Gaurav Oct 15 '08 at 17:56
  • No, it's an all or nothing thing. – Paul Dixon Oct 15 '08 at 18:25
0

MySql improves security which is good in one hand.

You can check this link for info on how to reset the password on multiple MySql versions.

https://www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mariadb-root-password

Stevan Tosic
  • 6,561
  • 10
  • 55
  • 110