Brillyints
Brillyints

Reputation: 87

Logging in to MySQL via command line with unusual password

In MySQL, I have a user with a password that has a "<" in it.

CREATE USER me IDENTIFIED BY 'ab>cd';

I can log perfectly in using this username and password using the MySQL Query Browser. Great. But then when I try to log in using the command line, it fails.

C:\Program Files\MySQL\Server\bin>mysql -u me -pab>cd
ERROR 1045 (28000): Access denied for user 'me'@'localhost' (using password: YES)

Unfortunately this seems to be causing the same problem with my MySQL connection string in my .NET application because I get the same exception message.

Of course this works just as it should...

CREATE USER me2 IDENTIFIED BY 'abcd';

and

C:\Program Files\MySQL\Server\bin>mysql -u me2 -pabcd
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.1.31-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Any help?

Upvotes: 1

Views: 420

Answers (1)

Vinko Vrsalovic
Vinko Vrsalovic

Reputation: 340386

Try escaping the > sign via using quotes.

C:\Program Files\MySQL\Server\bin>mysql -u me -p"ab>cd"

If you use the > as is it's interpreted by the command line as a redirection operator, it saves the output of the command (not error, only output which is why you can see the error) in a file.

In fact, because of your problem you should now have a file named cd in the directory where you were executing the commands.

Upvotes: 2

Related Questions