How to import .sql file into MySQL using PowerShell script?

Question:

I’m trying to import a dump file (.sql file containing CREATE/DROP/INSERT commands) into a remote MySQL server from a windows environment. I’ve got this PowerShell script to do the job for me by using “MySQL shell utility” functionalities installed in my environment

I can connect to the server and execute basic SELECT queries, using ExecuteNonQuery()/ExecuteScalar()/ExecuteReader() methods, but receiving an error for this specific SOURCE command:

I tried several alternatives to enter the path, like using double slashes or double backslashes but encountered the same error. Can anyone help on this?

Answer:

Source:

How to import .sql file into MySQL using PowerShell script? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply