Access denied for user 'root'@'%' (using password: YES) with mysql hosted in GCP

1,295 views
Skip to first unread message

Vinod Kumar

unread,
Aug 4, 2020, 9:53:54 AM8/4/20
to Google Cloud SQL discuss
I have created a GCP SQL Instance and trying to load a CSV file into mysql table using below query.

    LOAD DATA  INFILE 'D:/test.csv' 
    INTO TABLE discounts 
    FIELDS TERMINATED BY ',' 
    ENCLOSED BY '"'
    LINES TERMINATED BY '\n'
    IGNORE 1 ROWS
    (title,@expired_date,amount)
    SET expired_date = STR_TO_DATE(@expired_date, '%m/%d/%Y');


But getting below error.
Error Code: 1045. Access denied for user 'root'@'%' (using password: YES) 

George (Cloud Platform Support)

unread,
Aug 4, 2020, 11:29:47 AM8/4/20
to Google Cloud SQL discuss
Hello Vinod, 

In such cases, you are not supposed to use a system user (such as root@localhost) as the DEFINER for triggers, view, or stored procedures. Cloud SQL is a managed environment, and the root user has all privileges except SUPER and FILE. You should formulate your queries accordingly. 

The actual procedure to import data into a Cloud SQL instance is detailed on the "Importing data into Cloud SQL" documentation page, consisting in: 

1. Go to the Cloud SQL Instances page in the Google Cloud Console.
2. Select the instance to open its Overview page.
3. Click Import in the button bar.
4. Under Choose the file you'd like to import data from, enter the path to the bucket and SQL dump file to use for the import. Or to browse to the file:
   a. Click Browse.
   b. Under Location, double-click the name of the bucket in the list.
   c. Select the file in the list.
   d. Click Select.
You can import a compressed (.gz) or an uncompressed (.sql) file.

5. For Format, select SQL.
6. Select the database you want the data to be imported into.
    This causes Cloud SQL to run the USE DATABASE statement before the import.

    * If your SQL dump file includes a USE DATABASE statement, it overrides the database you set in the console.
7. Click Import to start the import.
Reply all
Reply to author
Forward
0 new messages