Reputation: 823
I am trying to connect to a sql database with the following code line below:
mysql_connect('localhost','root','');
When i edit the localhost to something else it gives an error. When i edit the password argument to something else it gives an error. This is not unexcepted, but when i edit the username which is root it does not give a error. Why does not it give a error on the username. It seems like i can connect with any username. Have i done anything wrong ?
Upvotes: 2
Views: 201
Reputation: 11142
You will most likely be able to "connect" but won't be able to actually do anything as far as run a query. If you run
SELECT * FROM mysql.user
you will probably see a row that looks something like this:
Host User Password Select_priv ...
localhost '' '' N
The database has an empty user/password record with no privileges for any table. Therefore, if you connect with a user that does not exist (password will have to be empty, otherwise you will get an access error) you will actually be able to connect but not actually do anything
Upvotes: 1