Category: MySQL

How to solve error SQL Import Google Cloud

Is it possible that when you try to import a backup of your MySQL database on Google Cloud, you have the following error :

We are trying to import a backup in Google Cloud SQL
The following error appears in the logs
error: exit status 1 stdout(capped at 100k bytes): stderr: ERROR 3546 (HY000) at line 26: @@GLOBAL.GTID_PURGED cannot be changed: the added gtid set must not overlap with @@GLOBAL.GTID_EXECUTED

To solve the problem, open the SQL file with text editor and search the error “@@GLOBAL.GTID_EXECUTED”

After modifying the *.sql file, you should be able to import successfully :

It should now work

Import / Export MySQL Workbench tables in Google Cloud SQL database

If you have a database on Google Cloud and you want to import and export some tables to another database, you will need a database explorer to export your .SQL backup.

Export the tables you want in database

Google Cloud interface only allow to export all a database or a specific database, but not tables

As you can see you don’t have the option to select tables.
To do so, you will have to connect the database with a SQL explorer.
In MySQL Workbench you should go in Server > Data Export

Then you should be able to select the tables you want

select Export to Self-Contained File to have a .SQL file

Import the SQL file to Google Cloud

You will need to upload the SQL file to Google Cloud in order to import it. In order to do it, go to Google Cloud > Cloud Storage, create the bucket if it doesn’t exist yet :

create the bucket dedicated for SQL, with random numbers, to have a unique name
Upload the SQL file generated by MySQL Workbench

Then, you can go on Google Cloud > SQL > Import

Select the SQL file from the bucked and select the database you want the tables to be imported

And then you should have imported successfully the tables on the selected database. You should check it in Operations


In case of errors, check the error in Operations, and modify the .SQL file with a text editor, search the error in the SQL file and remove the lines, and repeat the process (upload it again to Google Cloud Storage and import the SQL file again)

Install MariaDB on a Fedora/CentOS/RedHat server

If you have your own server, the first thing you may want to do with your backend shoud be to install a database server on it.

Here is step by step how to install a MySQL/MariaDB (almost the same) database on your server:
Install the MariaDB service:

yum install mariadb mariadb-server

Create your user access – change the username and password you want:

mysql
CREATE USER username@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' ;
flush privileges;

Verify the user has been created:

SELECT User FROM mysql.user;

You should be able to login on your database from you app and remotely.

Google Cloud SQL : SUPER privilege error while importing

When importing SQL file on Google Cloud (MySQL 5.7), I faced the following error:

exit status 1 ERROR 1227 (42000) at line 18: Access denied; you need (at least one of) the SUPER privilege(s) for this operation  

You can see the error when go in “Operation”, you can see the logs of the MySQL instance

In order to solve this problem, you should understand that we do not have SUPER privileges on the Google Cloud SQL instance, it means if you do “SHOW GRANTS” on your MySQL, it will tell you that you have almost all the rights but not all.

This problem happen when you try to import some specific things such triggers, views, … so you should be careful on the SQL export when you do it.
As for me, I’m using MySQL Workbench 8.0, it seems that by default I have this error when I try to import the SQL file generated on Google Cloud.
I tried to import an export from Google Cloud to another instance and seems to work, so the problem is when you export the SQL file it should not contains things that needs specific privileges.
I found a configuration that worked for me and now I don’t have this annoying error anymore. Great !
Here is the options I have used. First, when you export, go to Advanced Options…


Then you should check the following options:

Now you can try to import the SQL file on Google Cloud, it should works ! F*ck yeah!