I need to execute a sql file using the mysql client in a python script (I can not execute the queries using a python mysql module), the database is a MySQL instance on GCloud, I'm connecting to that instance using cloud_sql_proxy
.
I launched my_sql_proxy
using tcp like so:
./cloud_sql_proxy -instances=<my_instance>=tcp:12367
And I'm trying to execute the sql script like so:
gunzip -c <filename>.sql.gz 2>&1 | mysql --host=127.0.0.1 --port=12367 --user=<user> --password=<password> <dbmane>
This produces the following error:
ERROR 1045 (28000): Access denied for user '<myuser>'@'cloudsqlproxy~<some ip>' (using password: YES)
I obviously checked user/pwd/instance are correct.
The same command pointing to a mysql instance actually hosted on localhost is working.
With the same cloud_sql_proxy
process running I am able to connect using Sequel Pro
client with the same auth info and I am able to connect to the db using the following command:
/rnd/pos/components/mysql --host=127.0.0.1 --port=12367 --user=<myuser> -p <dbname>
>>> Enter password:
>>> Welcome to the MySQL monitor. Commands....
When connected, this is the output (masked) of SELECT USER(), CURRENT_USER();
+--------------------------------------------+-------------------------------------------------+
| USER() | CURRENT_USER() |
+--------------------------------------------+-------------------------------------------------+
| <my user>@cloudsqlproxy~<same ip as above> | <my user>@cloudsqlproxy~<part of the same ip>.% |
+--------------------------------------------+-------------------------------------------------+
I tried with -p[password]
and --password[=password]
, same output.
Why the --password is blocking? Is it a cloud_sql_proxy
config? Or is it a MySQL instance setting?
I googled and stackoverflowed but can't find anything relevant to my case.