Background
XAMPP is the most popular PHP development environment including a great GUI - phpMyAdmin, I would like to connect it to a cloud MySQL DB - Google Cloud Platform MySQL.
Requirement
- XAMPP installed
- Create a Google Cloud Platform (GCP) account
Solution steps
- Go to Google Cloud Platform (GCP)
- Select SQL from the sidebar
- Create a MySQL instance, please do keep your password
- Wait a few minutes for Google setup the MySQL instance
- Click your instance name
- Go to overview tab and copy MySQL IP address,
e.g. 1.2.3.4
- Open XAMPP phpMyAdmin Config, located in
XAMPP > Apache > Config > phpMyAdmin(config.inc.php)
Edit following lines in the configuration
/* Paste username / password */ $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = '<your password>'; /* Paste MySQL ip address */ $cfg['Servers'][$i]['host'] = '1.2.3.4';
- Go to Authorization(連線設定) tab
- Click
Add network
under public ip - Paste your ip address, which could be found through What is my ip
- Start XAMPP Apache, go to http://localhost/phpmyadmin/ and find it is connected, enjoy :)