Search code examples
mysqlphpmyadminremote-connection

Enable remote connection to a MySQL database on Debian


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


Solution

  • 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.