-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMigrate a MySQL Database to Google Cloud SQL
48 lines (24 loc) · 1.12 KB
/
Migrate a MySQL Database to Google Cloud SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Just run these commands IN SEQUENCE ----------
1ST TASK --------------
export ZONE=us-central1-a
gcloud sql instances create wordpress --tier=db-n1-standard-1 --activation-policy=ALWAYS --gce-zone $ZONE
2ND TASK ---------------
gcloud sql users set-password --host % root --instance wordpress --password Password1*
export ADDRESS= EXTERNALIP of BLOG VIRTUAL MACHINE/32 - CIDR FORM
gcloud sql instances patch wordpress --authorized-networks $ADDRESS --quiet
gcloud compute ssh blog --zone=us-central1-a
MYSQLIP=$(gcloud sql instances describe wordpress --format="value(ipAddresses.ipAddress)")
mysql --host=[SQL INSTANCE PRIMARY ADDRESS] \
--user=root --password
CREATE DATABASE wordpress;
CREATE USER 'blogadmin'@'%' IDENTIFIED BY 'Password1*';
GRANT ALL PRIVILEGES ON wordpress.* TO 'blogadmin'@'%';
FLUSH PRIVILEGES;
exit
3RD TASK -----------------
sudo mysqldump -u root -pPassword1* wordpress > wordpress_backup.sql
mysql --host=$MYSQLIP --user=root -pPassword1* --verbose wordpress < wordpress_backup.sql
sudo service apache2 restart
4RTH TASK ----------------
cd /var/www/html/wordpress
sudo nano wp-config.php