-1

MySql is installed on a Ubuntu server. I am running Windows 8.

Logging in through Putty. I can log in to database with both root and webadmin user accounts. I can also log in through my browser, using <server ip address>/phpmyadmin

My problem is when I try to use command line to log in. I am trying that approach because I am developing a webpage to access the database on that server. It fails to connect, so I thought if command line works, the webpage will also work.

commandline:

mysql -u webadmin -p

or

mysql -u root -p

error 1045 (28000): access denied for user 'webadmin'@'localhost' (using password: yes)

I added an iptables entry to allow mysql and that didn't work. Also, the firewall on server is inactive.

Deepak Rai
  • 2,063
  • 3
  • 17
  • 31
Sam
  • 73
  • 9
  • Execute `SELECT user, host FROM mysql.user;` from putty. You need to allow the mysql users access through some other hosts than the ones listed in the result of above statement. – hjpotter92 Mar 04 '15 at 22:07
  • I added the same usernames @ '%', shouldn't thta do it? – Sam Mar 04 '15 at 22:32
  • https://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw?rq=1 – hjpotter92 Mar 05 '15 at 00:35

1 Answers1

0

You need to grant access to the database. You can read the documentation here: https://dev.mysql.com/doc/refman/5.1/en/grant.html

You can run the following (but be careful as it will leave your DB open)

GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

That will allow root to connect from any IP and do any operations to the DB. If that still doesn't work, you might also need to run the following before the 2 lines above

CREATE USER 'root'@'%' IDENTIFIED BY PASSWORD '[your password]';
Augusto
  • 26,525
  • 5
  • 52
  • 82
  • I have done both of your suggestions earlier and no solution. which is why it is driving me crazy- – Sam Mar 04 '15 at 22:22