Mysql – Powershell script while executing thesqldump script

MySQLmysql-5.7mysqldumppowershellwindows

I'm having an error 1045: Access denied for user 'mysqlsuperuser'@'test.internal.cloudapp.net' (using password: YES) when trying to connect

Here is the mysqldump command on my ps1 file.

$command = [string]::format("`"{0}`" -u {1} -p{2} -h {3} --default-character-set=utf8mb4 --quick --master-data=2 --single-transaction --routines --databases test1 --add-drop-database --result-file=`"{5}`" ",
        $mysqlDumpLocation,
        $databaseUsername,
        $databasePassword,
        $databaseIp,
        $database.DatabaseName,
        $saveFilePath);

But when I try to remove the {2} which is the DB password, then execute the ps1 file. When it prompt me for the password, it goes through.

Best Answer

I would guess that there's one or more characters in the password that are "confusing" the shell.

There are standard techniques for supplying passwords to mysql utilities that avoids having to have them coded into scripts or visible to any process list run on the machine. See this answer.