Skip to content

Instantly share code, notes, and snippets.

@a6y3ap
Created August 19, 2022 19:29
Show Gist options
  • Save a6y3ap/894e9afe7d549abcab51cc266a2b5dde to your computer and use it in GitHub Desktop.
Save a6y3ap/894e9afe7d549abcab51cc266a2b5dde to your computer and use it in GitHub Desktop.
How to use MySQL Command Line with special characters password

How to use MySQL command line with special characters password

You must do this if the password has any of the following characters:

* ? [ < > & ; ! | $ ( )

🟥 Important Note: Make sure there is no space after -p and MySQL password.

Method 1

Use quotes around the password:

mysql -u root -p'Special*Character?Password()'

Method 2

Use bash variables

P='Special*Character?Password()'
mysql -u root -p$P

Method 3

Backslash (\) those special chars.

mysql -u root -pSpecial\*Character\?Password\(\)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment