Hello,
I am trying to import data from a CSV file that is stored in a Bucket. The CSV file uses the “|” delimiter. I would like to import this data into a MySQL database on Cloud SQL.
However, it seems that the root user does not have the “File” privilege, which means I cannot perform this import via MySQL Workbench.
Could anyone guide me on how I can carry out this task? Any help or direction would be greatly appreciated.
Thank you!
I hope this helps! If you need further assistance, feel free to ask.
Importing CSV data into Cloud SQL when you don't have root user FILE privileges can be done in a few ways. Here are common approaches:
Method 1: Using the Cloud Console Import Feature
Navigate to your Cloud SQL instance:
Access the Import option:
Configure the import:
Initiate the import: Click the Import button to start the process.
Method 2: Using the gcloud sql import csv Command
Install the Google Cloud SDK: Follow the instructions from Google Cloud SDK Installation.
Run the gcloud sql import csv command:
gcloud sql import csv [YOUR_INSTANCE_NAME] gs://[YOUR_BUCKET_NAME]/[YOUR_CSV_FILE.csv] \ --database=[YOUR_DATABASE_NAME] \ --table=[YOUR_TABLE_NAME] \ --fields-terminated-by=|
--fields-terminated-by=|
part specifies the pipe delimiter.Method 3: Using Client-side Tools (Note: Limited Applicability in Cloud SQL)
LOAD DATA LOCAL INFILE
. However, this method typically requires the FILE
privilege, which might not be available in Google Cloud SQL due to managed service constraints.Additional Considerations:
The first option you mentioned is not possible because the console does not have the option to choose the import delimiter. Is it a cons version issue?
I have already tried the other options with the exception of installing the SDK, but as I use the company's notebook this installation is not allowed.