I have a website that I should put on my domain.I have encountered an issue when I tried connecting to MySQL database so my code is not working. When I put
define("DB_HOST","http://domain");
define("DB_USER","user");
define("DB_PASS","password");
define("DB_NAME","dbName");
$connection = mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME);
if(!$connection){
die();
}
mysqli_set_charset($connection,"utf8");
I get this error in log
Failed to connect to MySQL: Plugin http could not be loaded: /usr/lib64/mysql/plugin/http.so: cannot open shared object file: No such file or directory
otherwise, I tried to remove that HTTP and just use the domain as DB_HOST, but then I get error
define("DB_HOST","mydomain.com");
define("DB_USER","user");
define("DB_PASS","password");
define("DB_NAME","dbName");
$connection = mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME);
if(!$connection){
die();
}
mysqli_set_charset($connection,"utf8");
PHP Warning: mysqli_connect(): (HY000/2002): Can't connect to MySQL server on 'domain.com' (115) in /home3/domain/public_html/a/i.php on line 7
Can anyone please help me find the solution to make this work?
http://domainis wrong, anddomain.comis wrong if the mysql server is not open to the internet and the user is allowed to connect from any host. If you're on shared hosting enter the details provided by your host. If your working on one server like a VPS and mysql is installed locally use localhost or 127.0.0.1 for the domain. You need to provide more details about the setup.