I am planning to setup a portal where end users can create mysql database in there dev environment. I am using XAMPP to setup the portal.
Now I need to create a remote DB (hosted on UNIX server) from windows server using the portal. I am using PHP
to create DB form.
Following is the code I use-
<?php
//Attempt MySQL server connection on remote host server.
$link = mysqli_connect("test.server.com", "mysqladmin", "pass");
// Check connection
if($link === false){die("ERROR: Could not connect. " . mysqli_connect_error());}
// Attempt create database query execution
$sql = "CREATE DATABASE vikas ";
if(mysqli_query($link, $sql)){echo "Database created successfully";}
else{echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);}
// Close connection
mysqli_close($link);
?>
Here test.server.com
is a remote server hosted on UNIX.
I am trying to create from windows server where XAMPP
is installed.
When I run the query I see that instead of going to remote server it is searching on localhost only.
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'mysqladmin'@'dev-windows.server.com' (using password: YES) in C:\xampp\htdocs\login\create_db.php on line 4 ERROR: Could not connect. Access denied for user 'mysqladmin'@'dev-windows.server.com' (using password: YES)
dev-windows.server.com
is windows server where XAMPP
is installed and all websites will be created here only.
test.server.com
is remote db server hosted in UNIX