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 ?
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 ~/.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With