0

How can I connect to MySQL database online from localhost using php?

I have read through all I could laid my hands on but to no avail. I read through Connect to an online MySQL database from localhost, Connect to server database from localhost, Connect to server database from localhost and some as well but none of them helped.

I tried

$dbhost = 'infonetemonitor.com'; //$db['host'];
$dbuser = '****';//$db['user'];
$dbpass = '****';//$db['pass'];
$dbname = 'info1_quiz';//$db['dbname'];

//Mysqli
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if (mysqli_connect_errno()) {
    printf("MySQLi connection failed: ", mysqli_connect_error());
    exit();
}

But this error was generated:

Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'info1_senetorial'@'41.58.56.26' (using password: YES) in C:\wamp64\www\COSTMI\includes\liveconnect.php on line 10

I thought it could be due to the fact that I didn't add an ip to Remote MySQL so I did but still nothing change.

In the database, I tried to grant privileges

GRANT ALL PRIVILEGES ON info1_quiz.* TO 'info1_senetorial'@'41.58.56.26' WITH GRANT OPTION;

but this error was displayed:

MySQL said:

1044 - Access denied for user 'infon10'@'localhost' to database 'mysql'

How can I go about it?

2

1 Answer 1

0

Try to replace the host name with the Host IP address and check again. this should allow you to connect to the DB. If you want to connect with the domain name then you should configure MySQL to understand with the domain name associated in the apache.conf file.

Sign up to request clarification or add additional context in comments.

1 Comment

I tried it but still getting Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'infon10_senetorial'@'41.58.104.52' (using password: YES) in

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.