Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5054

How do I establish a connection to a remote database?

$
0
0

I'm just trying to understand the general concept.

I have a LAMP stack virtual machine instance on Google Cloud Platform with a MySQL database.

I have created a database already via the phpMyAdmin web interface.

My index.php file has php code which makes use of the data in that database.

Important: The project files are stored on my computer at home (locally).

Problem: I have a config.php and index.php files in my project, but don't know what I'm supposed to do to connect / "talk" to the database that's on the GCP vm instance.

I tried changing the 'DBHOST' value in my config.php to the database hostname but that obviously didn't do anything b/c I don't see how that's enough information to connect to the database.

This is my config.php file

<?phpdefine('DBHOST', 'localhost');define('DBNAME', 'business_covid');define('DBUSER', 'testuser');define('DBPASS', 'hidden');define('DBCONNSTRING','mysql:dbname=business_covid;charset=utf8mb4');?>

Do I need more info than this and is a correctly configured config.php file all that is needed to connect to a database?


Viewing all articles
Browse latest Browse all 5054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>