new question
new question

Reputation: 29

Cannot connect php site to mysql database?

Hi I developed a php website with mysql. It worked perfectly on localhost. I hosted my site and change database config file,

<?php 
    define("dbhost", "128.199.145.183");
    define("dbuser", "root");
    define("dbpass", "xxxxxxx");
    define("dbname", "database");

    $dbc = new mysqli(dbhost,dbuser,dbpass,dbname);

 ?> 

But it not worked. My site is working fine and when i tried to login i got an HTTP 500 error. How can i solve this?

Upvotes: 0

Views: 83

Answers (1)

Danyal Sandeelo
Danyal Sandeelo

Reputation: 12391

root database user doesn't have by default access to access database remotely.

you can verify this by looking at the mysql.user table

use mysql;
select * from user;

check if root has the ip access from %

I would recommend, create another user with limited rights on host as % (can access database remotely)

You can create user like this:

use mysql; 
create user testing@'%' indentified by 'testing_password';
grant all on *.* to testing; // you can specify databases or specific permissions
flush privileges;

Upvotes: 1

Related Questions