Para gerar uma estimativa de custo baseada na projeção de uso deste tutorial, use a calculadora de preços.
Novos usuários do Cloud Platform podem se qualificar para um teste gratuito do Google Cloud.
Antes de começar
In the Trusted Cloud console, on the project selector page,
select or create a Trusted Cloud project.
No campo URL da imagem do contêiner, insira phpmyadmin. O Cloud Run extrai a imagem do Docker Hub público.
No campo Nome da conta de serviço, insira phpmyadmin.
Verifique Require authentication.
Clique em Contêineres, volumes, rede, segurança para definir as seguintes opções:
No campo Porta, insira 80 como o valor da porta do contêiner.
Em Variáveis de ambiente, adicione PMA_HOST e defina o valor como o endereço IP interno da instância do Cloud SQL.
Em Rede, selecione Conectar-se a uma VPC para tráfego de saída e Enviar tráfego diretamente para uma VPC. Escolha a mesma rede da instância do Cloud SQL.
Conecte-se ao serviço usando o proxy Cloud Run
Para acessar com segurança o serviço protegido pelo IAM, use o proxy do desenvolvedor do Cloud Run.
Para iniciar o proxy no serviço criado anteriormente, utilize o seguinte comando:
gcloudrunservicesproxyphpmyadmin--port=8080
Se a CLI gcloud solicitar que você instale os componentes cloud-run-proxy, insira Y.
Para testar a configuração, insira o URL e o número da porta (por exemplo, http://127.0.0.1:8080/) e, em seguida, o nome de usuário (nome do administrador) e a senha. Como você está usando o proxy de desenvolvedor local do Cloud Run para acessar o serviço com segurança, talvez você veja uma mensagem de erro que pode ser ignorada: There is a mismatch between HTTPS indicated on the server and client.
Depois de concluir o tutorial, você pode limpar os recursos que criou para que eles
parem de usar a cota e gerar cobranças. Nas seções a seguir, você aprenderá a excluir e desativar
esses recursos.
Exclua o projeto
O jeito mais fácil de evitar cobranças é excluindo o projeto que você criou para o tutorial.
Para excluir o projeto:
In the Trusted Cloud console, go to the Manage resources page.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-18 UTC."],[],[],null,["# Use phpMyAdmin with Cloud SQL on Cloud Run\n\n*** ** * ** ***\n\nThis guide show how to install [phpMyAdmin](https://docs.phpmyadmin.net/en/latest/intro.html) on Cloud Run. You can use phpMyAdmin to administer Cloud SQL over the web.\n\n\u003cbr /\u003e\n\nYou will find this tutorial helpful if you:\n\n- Host applications on Cloud Run.\n- Use [Cloud SQL](/sql/docs) as your database.\n- Want to use phpMyAdmin as an interface for MySQL or prefer a web interface for database administration.\n\nObjectives\n----------\n\n- Learn how to deploy phpMyAdmin on Cloud Run.\n\nCosts\n-----\n\nThis tutorial uses billable components of Google Cloud,\nincluding:\n\n- [Cloud Run](/run/pricing)\n- [Cloud SQL](/sql/pricing)\n\nTo generate a cost estimate based on your projected usage, use the [Pricing Calculator](/products/calculator). \nNew Cloud Platform users might be eligible for a Google Cloud [free trial](/free-trial). \n\n\u003cbr /\u003e\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n [Install](/sdk/docs/install) the [gcloud CLI](/sdk/gcloud).\n\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n [Install](/sdk/docs/install) the [gcloud CLI](/sdk/gcloud).\n\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n\n1. Create a [Cloud SQL\n Second Generation instance](/sql/docs/mysql/create-instance#create-2nd-gen) with a [private IP](/sql/docs/mysql/configure-private-ip).\n2. Create a [database user](/sql/docs/mysql/create-manage-users#creating). \n\nCreate a service using the phpMyAdmin image\n-------------------------------------------\n\n### Console\n\n1. In the Google Cloud console, go to Cloud Run:\n\n [Go to Cloud Run](https://console.cloud.google.com/run)\n2. Select **Create service**.\n\n 1. In the **Container image** URL field, enter `phpmyadmin`. Cloud Run pulls the image from the public [Docker Hub](https://hub.docker.com/_/phpmyadmin).\n 2. In the **Service name** field, enter `phpmyadmin`.\n 3. Check `Require authentication`.\n 4. Click **Container(s), volumes, networking, security** to set the following options:\n 1. In the **Port** field, enter `80` for the value of the container port.\n 2. In **Environment variables** , add `PMA_HOST` and set the value to be the internal IP address of the Cloud SQL instance.\n 5. 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.\n\n | **Note:** You can also use a Serverless VPC Access instead of routing traffic directly to a VPC. In the [comparison table](/run/docs/configuring/connecting-vpc#comparison-table), learn the difference between the two ways.\n\nConnect to the service using Cloud Run proxy\n--------------------------------------------\n\nTo securely access the IAM-protected service, use the Cloud Run developer proxy.\n| **Important:** We don't recommend exposing phpMyAdmin to the public internet directly. If you prefer an alternative to the local proxy, you can configure [IAP](/iap/docs/enabling-cloud-run) to enforce user authentication.\n\n1. To start the proxy on the previously created service, use the following command:\n\n gcloud run services proxy phpmyadmin --port=8080\n\n If [gcloud CLI](/sdk/gcloud) prompts you to install the `cloud-run-proxy` components, then enter `Y`.\n2. To test the setup, enter the URL and port number (for example, `http://127.0.0.1:8080/`),\n and then with the username (admin name) and password. Since you're\n using the local Cloud Run developer proxy to access the service\n securely, you might see an error message, which can be ignored:\n `There is a mismatch between HTTPS indicated on the server and client`.\n\nTroubleshoot\n------------\n\nTo obtain information about Cloud Run errors, access the\n[Cloud Run logs](https://console.cloud.google.com/logs) in the [Google Cloud console](https://console.cloud.google.com/).\n\nClean up\n--------\n\n\nAfter you finish the tutorial, you can clean up the resources that you created so that they\nstop using quota and incurring charges. The following sections describe how to delete or turn off\nthese resources.\n\n\u003cbr /\u003e\n\n### Delete the project\n\n\nThe easiest way to eliminate billing is to delete the project that you\ncreated for the tutorial.\n\nTo delete the project:\n\n| **Caution** : Deleting a project has the following effects:\n|\n| - **Everything in the project is deleted.** If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.\n| - **Custom project IDs are lost.** When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an `appspot.com` URL, delete selected resources inside the project instead of deleting the whole project.\n|\n|\n| If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects\n| can help you avoid exceeding project quota limits.\n1. In the Google Cloud console, go to the **Manage resources** page.\n\n [Go to Manage resources](https://console.cloud.google.com/iam-admin/projects)\n2. In the project list, select the project that you want to delete, and then click **Delete**.\n3. In the dialog, type the project ID, and then click **Shut down** to delete the project.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### Delete instances\n\n\nTo delete a Cloud SQL instance:\n\n1. In the Google Cloud console, go to the **Instances** page.\n\n [Go to Instances](https://console.cloud.google.com/sql/instances)\n2. Click the name of the SQL instance you that want to delete.\n3. To delete the instance, click delete **Delete**, and then follow the instructions.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nWhat's next\n-----------\n\n- [Learn more about phpMyAdmin](http://www.phpmyadmin.net/home_page/docs.php).\n- Explore reference architectures, diagrams, and best practices about Google Cloud. Take a look at our [Cloud Architecture Center](/architecture)."]]