You will find this tutorial helpful if you:
- Host applications on Cloud Run.
- Use Cloud SQL as your database.
- Want to use phpMyAdmin as an interface for MySQL or prefer a web interface for database administration.
Objectives
- Learn how to deploy phpMyAdmin on Cloud Run.
Costs
This tutorial uses billable components of Google Cloud, including:
To generate a cost estimate based on your projected usage, use the Pricing Calculator.
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
- Create a Cloud SQL Second Generation instance with a private IP.
- Create a database user.
Create a service using the phpMyAdmin image
Console
In the Google Cloud console, go to Cloud Run:
Select Create service.
- In the Container image URL field, enter
phpmyadmin
. Cloud Run pulls the image from the public Docker Hub. - In the Service name field, enter
phpmyadmin
. - Check
Require authentication
. - Click Container(s), volumes, networking, security
to set the following options:
- In the Port field, enter
80
for the value of the container port. - In Environment variables, add
PMA_HOST
and set the value to be the internal IP address of the Cloud SQL instance.
- In the Port field, enter
In Networking, select Connect to a VPC for outbound traffic and Send traffic directly to a VPC. Choose the same network as the Cloud SQL instance.
- In the Container image URL field, enter
Connect to the service using Cloud Run proxy
To securely access the IAM-protected service, use the Cloud Run developer proxy.
To start the proxy on the previously created service, use the following command:
gcloud run services proxy phpmyadmin --port=8080
If gcloud CLI prompts you to install the
cloud-run-proxy
components, then enterY
.To test the setup, enter the URL and port number (for example,
http://127.0.0.1:8080/
), and then with the username (admin name) and password. Since you're using the local Cloud Run developer proxy to access the service securely, you might see an error message, which can be ignored:There is a mismatch between HTTPS indicated on the server and client
.
Troubleshoot
To obtain information about Cloud Run errors, access the Cloud Run logs in the Google Cloud console.
Clean up
After you finish the tutorial, you can clean up the resources that you created so that they stop using quota and incurring charges. The following sections describe how to delete or turn off these resources.
Delete the project
The easiest way to eliminate billing is to delete the project that you created for the tutorial.
To delete the project:
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
Delete instances
To delete a Cloud SQL instance:
- In the Google Cloud console, go to the Instances page.
- Click the name of the SQL instance you that want to delete.
- To delete the instance, click Delete, and then follow the instructions.
What's next
- Learn more about phpMyAdmin.
- Explore reference architectures, diagrams, and best practices about Google Cloud. Take a look at our Cloud Architecture Center.