Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create database on google cloud sql instance

How can I use Cloud SQL to create a database? When I use MySQL, I could easily run a sql script to create them on phpMyAdmin.

I found a site that advertises that it's possible to run SQL files right on Google Cloud SQL.

google run SQL files image

This is exactly what I want to do. I could run my code to create a couple databases, and they would be in my cloud SQL, and I could connect my appengine app to my cloudsql and it would work as expected.

But when I follow the instructions on that site, I only see this:

actual cloud SQL site image

Where is the SQL prompt? How can I create databases on my cloud sql instance?

like image 987
user2977732 Avatar asked Nov 11 '13 03:11

user2977732


People also ask

What command is used to create a database for an SQL instance on Google Cloud?

Create a MySQL instance. In the Google Cloud console, go to the Cloud SQL Instances page. Click Create instance. On the Choose your database engine panel of the Create an instance page, click Choose MySQL and click Next.

Can I host a database on Google Cloud?

For example, you can use the Google Cloud Platform Console to create and manage databases, schedule jobs, and access data through the Google Cloud Platform Dataflow platform. Overall, we believe that Google Cloud Platform is the best choice for hosting a database.

How can I create database in SQL Server?

In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance. Right-click Databases, and then select New Database. In New Database, enter a database name.


2 Answers

As @Juan Enrique Muñoz Zolotoochin says, singe February 2015 it is now possible to manage databases using the new Developer Console, making my original answer (below) obsolete.

New Answer

Open your project, expand Storage and then Cloud SQL, switch to the DATABASES tab. From there you can use the New database button to create a new database. You can also delete databases from there.

Original Answer (Now obsolete)

This has not been implemented in the new Cloud Console yet, you have to use the old api's console for this.

To get to it first go to the Cloud SQL section of your project in the new console (where you are). Then in the bottom right there is a link "Return to original console". If you click on this you get to a slightly different control panel for Cloud SQL.

If you then click on the instance you want to create your database on, you will get another screen that has a "SQL Prompt" tab, click on that and then you can execute raw SQL commands against it.

UPDATE: To get to the old APIs console and prevent the redirect taking you to the new console use this link: https://code.google.com/apis/console/b/0/?noredirect

like image 160
IanGSY Avatar answered Oct 19 '22 23:10

IanGSY


UPDATE (2015-02-13): You can now use the Developer Console UI to manage your MySQL databases. Just go to your Cloud SQL instance page and click on the Databases tab.

ORIGINAL ANSWER (still works): If you have a MySQL client installed it is fairly easy to connect to your Cloud SQL instance and create a new Database.

  1. Go to the Access Control section of your Cloud SQL instance.
  2. If you haven't done it, get an external IP Address.
  3. From the same page, set the password for the root user.
  4. Whitelist yourself by adding a new Authorized Network and entering your IP.

Then, if you're using the standard mysql command line client, go a to a terminal and run

mysql -uroot -p<your-root-password> -h<your-cloudsql-instance-ip>

Or you can just use any client you want.

Once you've connected to you database you can just CREATE DATABASE MyDatabase.

like image 37
Juan Enrique Muñoz Zolotoochin Avatar answered Oct 19 '22 22:10

Juan Enrique Muñoz Zolotoochin