Reputation: 686
I have a problem when I try to connect with an external MySQL server
Here the error message :
acces is denied for user :
"user"@"myip"
When I change port number, I get different error :
$connection =mysql_connect("192.96.206.145:8443","user","password")or die( mysql_error() );
if(!$connection)
{
echo 'It\'s impossible to connect with the server ! check you connection or try later ';
//exit;
}
else
{
if (!mysql_select_db($gamedatabase,$connection))
{
echo'we have problem in our server plz try again later ! ';
//exit;
}
else
{
$etat=true;
}
}
Upvotes: 1
Views: 200
Reputation: 7785
You have 2 different Server :
Server A : Apache + PHP
Server B : MySQL
Go to the Server A
Get his IP address : you can type ipconfig
command
(I will suppose that the IP address is SO_IP)
Go to the Server B
Add MySql\bin
to your PATH
environment variable
Executes these commands :
mysql --user=root mysql
CREATE USER 'SO_USER'@'SO_IP' IDENTIFIED BY 'SO_PASS';
GRANT ALL PRIVILEGES ON *.* TO 'SO_USER'@'SO_IP' WITH GRANT OPTION;
Return to your Server A and change the PHP connection code
$connection =mysql_connect("SERVER_B_IP_ADDRESS:3306","SO_USER","SO_PASS")or die( mysql_error() );
Upvotes: 1
Reputation: 1265
This error is characteristic of an incorrect database password. If it's giving you an access denied error that means that it can find the database, it just can't log in to it with the provided information.
Also may I suggest using mysqli instead of mysql, as the improved version is much more secure.
Double check your password. Can you access the database by any other means such as phpmyadmin / a database editor such as navicat?
Upvotes: 1
Reputation: 2815
Are you sure that your MySQL-Server is running on Port 8443? Normally, that is 3306.
Is your MySQL server and user enabled for external access? I mean bind_address and the settings in the user table of MySQL. (Is there any firewall blocking access?)
Furthermore, you should MySQLi-extension as MySQL is deprecated.
Upvotes: 2