Reputation: 21
I can access phpMyAdmin and administrate my database.
I created a database "DB", a user "USR" with a password "PSWD" who only has access to "DB" and can only SELECT, INSERT and UPDATE.
But when I launch the shell through XAMPP and type
mysql --database=DB --user=USR --password=PSWD
I get an "access denied" error (and yes, I restarted the service).
Same thing happens when I try to access my database from my index.php script.
EDIT : Ok, I managed to pin point the cause of my problem, but it doesn't make any sense : It's the '%' wildcard in the host column that just doesn't work. If I put 'localhost' instead, then connecting from localhost works. The thing is, I actually NEED to access that database from anywhere... So what can I do ?
Upvotes: 0
Views: 1175
Reputation: 3738
Try
mysql -u root
if it works, check user's Hosts
USE mysql;
SELECT User, Host FROM user;
It should look like
+--------------+-----------+
| User | Host |
+--------------+-----------+
| yourusername | localhost |
+--------------+-----------+
| yourusername | 127.0.0.1 |
+--------------+-----------+
If you dont have localhost
you need to add a record with it.
If connecting to Mysql with root and no password did not work, please try,
mysql -u your_username -p password -h 127.0.0.1
And check user's Hosts (explained in previous steps)
Upvotes: 1
Reputation: 171
Can you try the following: mysql --user=USR -p
Once you press enter, you will be prompted for password. Enter it and you can switch to database using: use db;
Upvotes: 0