Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql logging in even without providing password

Tags:

mysql

mysql logging in the prompt even not providing password , If provided like mysql -u root -p its prompting for password if provided like mysql -u root its logging in without asking for password i have run the query

select user,hosts from mysql.user; 

and came to know there are 3 root users with different hosts as shown

+------+-------------+
| user | host        |
+------+-------------+
| root | 127.0.0.1   |
| root | db-busindia |
| root | localhost   |
+------+-------------+

And interesting thing is that mysql server name is also db-busindia , is root@'db-busindia' the culprit ?

like image 385
mviswa Avatar asked Oct 26 '13 07:10

mviswa


People also ask

Why can I login to MySQL without password?

my. cnf file in your user's home directory, MySQL would allow you to login without prompting you for a password. Make sure to update your MySQL credentials accordingly, then save the file and exit. After that, if you run just mysql you will be authenticated directly with the credentials that you've specified in the ~/.

Can we connect to MySQL as root without password?

How to Set MySQL Root Password. In case you have freshly installed the MySQL/MariaDB server, then it doesn't require any password to connect to it as root user.

Is there a default MySQL password?

The default user for MySQL is root and by default it has no password. If you set a password for MySQL and you can't recall it, you can always reset it and choose another one.


1 Answers

Check the [client] section of my.cnf file for the lines:

user=root 
password=some text.

These enable you to log in without a username or password. Delete password line, if you want to be prompted for password.

like image 177
user4035 Avatar answered Oct 05 '22 16:10

user4035