3

I have installed a MySQL database on a Debian Lenny 5.0 and I am trying to connect to that database remotely using PHP.

This is the way I'm logging in:

$con = mysql_pconnect("MY_IP_ADDRESS","root","MY_PASSWORD");
if (!$con)
die('Could not connect: ' . mysql_error());

and this is the error I get:

Could not connect: Access denied for user 'root'@'li273-10.members.linode.com'
(using password: YES)

Which Im not sure why my linode user appears there.

To enable remote connections I used this tutorial: http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

Another thing I've noticed, in my phpmyadmin on the MySQL side I have this:

Server: localhost via TCP/IP
Server version: 5.0.51a-24+lenny5
Protocol version: 10
User: root@mycooldb

Which I think that localhost has to be my server's IP Address?

What I'm I doing wrong?

Few thing that didnt work from the tutorial:

Saving all rules: service iptables save doesn't work. I get this error:

-bash: service: command not found

Last, when I do mysql -u webadmin –h MY_IP –p I get this: enter image description here

user
  • 23,260
  • 9
  • 113
  • 101
jQuerybeast
  • 14,130
  • 38
  • 118
  • 196
  • possible duplicate of [Enable remote MySQL connection](http://stackoverflow.com/questions/8380797/enable-remote-mysql-connection) – user Mar 10 '14 at 03:33

1 Answers1

5

You need to create a user / permissions for the remote user as well. Likely the root user has permissions defined only as root@localhost.

You'd need to define a user permission like: user@% or user@li273-10.members.linode.com.

http://dev.mysql.com/doc/refman/5.0/en/create-user.html

You probably don't want to give a super user account (root in this case) remote access.

Your hostname is appearing in the authentication line because you actually connect to the db as user@hostname.

jasonbar
  • 13,333
  • 4
  • 38
  • 46
  • Will this create user 'user' with password 'password' and give full privileges? GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; – jQuerybeast Mar 09 '12 at 21:37