Possible Duplicate:
PHP – connecting to mysql database from different server
global $host, $username, $password, $database;
$host = "meshtelecom.com";
$username = "mesh_project";
$password = "password";
$database = "mesh_database";
$link = mysql_connect($host, $username, $password);
if(!$link)echo "Connection failed.";
$db = mysql_select_db($database)or die(mysql_error());
I made a database with phpmyadmin in meshtelecom.com. I can’t access this database from another server.. it’s giving me:
Connection failed.Access denied for user ''@'localhost' to database 'mesh_database'
You have to create a new account for the user for accessing the host from other servers.
You currently have user ‘mesh_project’@’localhost’ but you also need to have ‘mesh_project’@’%’.
Or if you want to restrict which hosts can be used to connect to the database, you can use hostname or IP instead of %.
Here’s some documentation http://dev.mysql.com/doc/refman/5.5/en//adding-users.html
If you can log in from command line, run these commands:
Change ‘password’ to something else and add only privileges you want the user to be able to perform. Giving too much power to be accessible from any host increases security risk.