How to import data via MySQL Workbench with SSH?

How to import data via MySQL Workbench with SSH?



I'm trying to upload data to my MySQL database on the PythonAnywhere server hosting via SSH (I have a paid account). I have three databases (alter$default, alter$ip_data and alter$visitor_data) from within the PythonAnywhere interface.


alter$default


alter$ip_data


alter$visitor_data



Using the online instructions (here) I can successfully connect to the server via SSH using MySQL Workbench, and see the three databases in the schemas window (Click here to view image of schemas list).



I can successfully add tables to the database of my choice, but when I try to add data I get Error Code: 1045. Access denied for user 'alter'@'%' (using password: YES).


Error Code: 1045. Access denied for user 'alter'@'%' (using password: YES)



I have tried troubleshooting:



For SELECT user(); it returns alter@10.0.0.89


SELECT user();


alter@10.0.0.89



For SELECT current_user(); it returns alter@%


SELECT current_user();


alter@%



For SHOW GRANTS; it returns:


SHOW GRANTS;


GRANT USAGE ON *.* TO 'alter'@'%' IDENTIFIED BY PASSWORD <secret> WITH MAX_USER_CONNECTIONS 6
GRANT ALL PRIVILEGES ON 'alter$default' .* TO 'alter'@'%'
GRANT ALL PRIVILEGES ON 'alter$visitor_data' .* TO 'alter'@'%'
GRANT ALL PRIVILEGES ON 'alter$ip_data' .* TO 'alter'@'%'



It appears that I have the necessary privileges granted and am correctly connected to the MySQL server - so why will it not let me write to the database? Is the .csv file in the wrong place? I can't use the 'root' user as that is surely the PythonAnywhere administrator account?



Extra details:
The SQL query for writing to the database - that returns "access denied" - is:


LOAD DATA INFILE 'VALUES.CSV'
INTO TABLE ip_data_table
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY 'rn'
IGNORE 0 LINES;




1 Answer
1



It's the infile that is causing the permission denied. You need to start the mysql client with the --local-infile=1 flag.






And I think it should also be LOAD DATA LOCAL INFILE.

– Giles Thomas
Sep 14 '18 at 13:15


LOAD DATA LOCAL INFILE






That's right, using both --local-infile=1 and LOAD DATA LOCAL INFILE in combination from the Bash command line has fixed the issue. Thank you!

– excom
Sep 15 '18 at 1:13



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ