LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   MySQL: Need To Escape "!" In MySQL Prompt (http://www.linuxquestions.org/questions/linux-server-73/mysql-need-to-escape-in-mysql-prompt-940872/)

GraysonPeddie 04-20-2012 12:07 PM

MySQL: Need To Escape "!" In MySQL Prompt
 
Let's say that you're in a MySQL prompt and you are trying to create a user and grant a single database access to the user.

Example:

Code:

CREATE USER `ecommerce` IDENTIFIED BY `tH!s!SmYP@s$w0rDd0N0tUs3!T';
If I try to execute it, I will be stuck in > like this:

Code:

mysql> CREATE USER `ecommerce` IDENTIFIED BY `tH!s!SmYP@s$w0rDd0N0tUs3!T';
    `>
    `>
    `>
    ...

So how can I escape the exclamation mark?

"\!" wouldn't work because I'll get:

Code:

Unknown command '\!'.
Pardon me if this question have already been asked, but I've searched in Google for quite a while and I couldn't find what I'm looking for.

PS: If only I can create tags for exclamation mark and exclamation point. For someone searching in the Internet with the same problem that I have can find my thread a lot quickier with the two tags that I couldn't create.

TB0ne 04-20-2012 12:24 PM

Quote:

Originally Posted by GraysonPeddie (Post 4658522)
Let's say that you're in a MySQL prompt and you are trying to create a user and grant a single database access to the user.
Example:
Code:

CREATE USER `ecommerce` IDENTIFIED BY `tH!s!SmYP@s$w0rDd0N0tUs3!T';
If I try to execute it, I will be stuck in > like this:
So how can I escape the exclamation mark?

"\!" wouldn't work because I'll get:
Code:

Unknown command '\!'.
Pardon me if this question have already been asked, but I've searched in Google for quite a while and I couldn't find what I'm looking for.

Two problems: you're using back-ticks not single quotes, and you're putting something around the user ID. This:
Code:

CREATE USER ecommerce IDENTIFIED BY 'tH!s!SmYP@s$w0rDd0N0tUs3!T';
..works fine.

GraysonPeddie 04-20-2012 12:30 PM

Thanks for your help. My SQL knowledge is getting a little bit rusty. :)

I saw from the web page in step 3:

Code:

CREATE USER ‘aspnet’ IDENTIFIED by ‘aspnetpassword’;
...which gave me a problem with user creation in MySQL.


All times are GMT -5. The time now is 09:31 PM.