MySQL (MariaDB) in the Cloud

Each student will install and be DBA for their own MariaDB server running in the Google cloud.

1. You will need a Google account. If you use gmail or login to Google in Chrome, you already have this. If not, there is a link for account creation in step 2 here.

2. Sign up for a free Google cloud account. See Linux VM Quickstart. This page has two big buttons (numbered 1. and 2.) for two important first steps to do, creating a project and enabling billing for it. Name your project cs634-username, where username is your username. Enable billing for it as shown in this quickstart. This will require info on a credit/debit card (or bank account), but it won't be charged. See their FAQ. After enabling billing, go on to step 3 of this document, since its linked document shows more details of the next needed action.

Note on the Google website: The Google Cloud website is confusing at first because it refers to a huge number of concepts we don't need to use, and only shows part of the hierarchy on each screen. Perhaps they are trying to discourage hobbyists from trying to use this. The top of the "Console" hierarchy is the "home", is reachable by clicking the "hamburger" icon (triple bar) in the upper left corner of any page within the hierarchy and then the Home button. Clicking the hamburger icon also shows the top-level topics, and "Compute Engine" is the one that supplies the VM we want. We'll also need to use "IAM &admin" listed here. Under Compute Engine, we see "VM Instances", very important, but the others can be ignored at least to start.

3. Next start following How to Set Up MySQL on Google Compute Engine.  At the start of this document, you can skip down to "Objectives" if you want. Then follow the directions up to "Cleaning Up".  Here are the needed steps you need to follow in that document, and some comments on them.

a. You have already done "Create a new project". You can skip the gcloud-related substeps (1., 2., 3.) if you want (you could do them later if you want to control your VM from your development system's command line.)

b. Next do "Create a Compute Engine Instance". When you create the "instance" (the VM) , you can see more info on this step in the Linux VM Quickstart linked above. Name your instance using the first two or three characters of your username followed by vm, for example user eoneil has eonvm. This name will show up in the shell's prompt. Use all default settings on sizing the system (CPUs, memory, disks), so as to stay within your $300 free charges limit for the whole semester (or year if you want). The default OS is Debian Linux, which is fine, and much like the Ubuntu Linux we have on pe07. Establish a SSH connection to your new VM instance as directed. If you can't see the SSH button, click the button SHOW/HIDE INFO PANEL once or twice. Don't use the "Cloud Shell", since that will connect you to an ephemeral VM, not your persistent VM.

c. Do "Install MySQL" (on Debian Linux), skipping running mysql_secure_installation (I don't think it's necessary) Note that no root password is set for the mysql server here, as the instructions suggest, but it isn't needed. The output from "select user, host, password from mysql.user" has only one row, with a blank password (OK, see note below on sudo and passwords). Ordinary mysql users (see step 3.)should have passwords.

d. Do "Connect to MySQL": Need "sudo mysql -u root" Note that when you want to run "mysql -u root" on your VM, on this version of MariaDB, you need to use sudo, as in "sudo mysql -u root".  For ordinary mysql users, "mysql -u user -p" works fine, just like on pe07.

e. Don't do the "Cleaning Up" actions, specifically, don't delete the project at the end. What you can do to minimize charges is shut down the VM at the end of your session for the day. To shut down your VM, find Dashboard>Compute Engine>VM instances, follow the link for your instance to the Instance Details page, and use the STOP button at the top. To get it going again, use the START button at the same place there. Try this out now but keep the VM running (mostly idling) for the first week, so I can log in as a check. You will see that only a dollar or less has been used up.

f. After a week or so, bring down the VM so it doesn't run for weeks on end.

3. Add yourself as a mysql user, with password same as your username, with a database of name username+"db", e.g. user joe has database joedb. Here are the basic commands for user joe:

create database joedb;
grant all privileges on joedb.* to joe@'%' identified by 'joe';

4. Set up as an additional "owner" of the project, with "Compute Engine>Compute Instance Admin(v1)" role, so I can login and help you if necessary. Find Home>IAM & admin>IAM, and click the ADD button at the top, and enter with role Compute Instance Admin (v1). Then find Home>IAM & admin>Service accounts, select your default account and click the PERMISSIONS button. In the Add member box, add with role owner.

5. Send email to listing your username, your Google username (but not your password), and your project name (hopefully cs634-username). I should be able to login to your VM when it's up, based on my own Google account linked to

Note on sudo and passwords: On most Linux systems "sudo command" prompts you for your system password. On Google's VMs, password security is replaced by network security (OAuth2), so system passwords are not used. So "sudo command" just runs the command as superuser, without requiring your password. It is assumed that since you are logged in, you have passed the security test. This does mean that anyone can mess with your system if you leave a logged in shell showing on your screen in your absence.