Export Database from Google Cloud Sql to external Database
Asked Answered
A

4

8

I'm trying to export my database created in Google Cloud Sql and import it into a new external server.

I tried to create a sql backup through the google console, downloaded it and copied it to the new server via filezilla and then launched the following command:

psql -U postgres -d ciclods-db -1 -f Backup-db_Cloud_SQL_Export_2019-03-23\ \(17_01_19\)

but i get this output:

ERROR: role "cloudsqladmin" does not exist REVOKE

ERROR: role "cloudsqlsuperuser" does not exist GRANT

what is the right procedure to follow in these cases?

Aristate answered 26/4, 2019 at 13:24 Comment(3)
I am facing the same issue. Did you find any solution.Overuse
I had the same issue and I just deleted these two lines from my script so I imported with success. I know that it is not the best to do however I just wanted to load the script in my machine to take a look into the data. Worked for my scenario.Quinquennial
faceing the same problem. Did anyone find solution for this?Marlea
B
3

In my case, my SQL file was around 10 GB. Hence, it wasn't possible to remove these two lines directly using the convention text editor. After searching around, I found that I could use sed to remove them. Here is the command:

sed '/cloudsqladmin\|cloudsqlsuperuser/d' backup.sql > fixedbackup.sql
Biegel answered 22/2, 2023 at 13:7 Comment(0)
M
2

I have resolved the same problem by locating and deleting the two lines from the exported sql file with "cloudsqladmin". My app does not use it anyway.

Marlea answered 25/5, 2021 at 0:34 Comment(0)
A
-4

to do this task you can follow the official GCP guide about How to export data from Cloud SQL[1] in that document they give you the option to export the data into a dump file or csv files which can be used for other tools.

https://cloud.google.com/sql/docs/mysql/import-export/exporting

Araldo answered 26/4, 2019 at 14:16 Comment(1)
yes but that file export roles that not exist and this raise an error-> ERROR: role "cloudsqladmin" does not exist REVOKEAristate
A
-4

In order to create the export file, you have to do it from a command line and use additional flags. As per documentation‘s “Exporting data to a SQL dump file”, there is a section on Exporting data from an externally-managed database server.

As well you can find there the option to export the data into a CSV file.

Araldo answered 30/4, 2019 at 15:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.