views:

27

answers:

2

Note: I'm using a bash shell on a nearly-fresh osx 10.6 install. This doesn't seem to happen to a friend who is on zsh

I'm used to Postgres, so I often instinctually type

\d tablename

instead of

desc tablename ;

When I do this, the mysql client is not very happy

mysql> \d items
mysql> ;
    -> desc items;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';
    ->

notice how my prompt changes after the 'oh crap' moment. It seems to lock into this routine where all sql commands are considered to have invalid syntax.

i haven't figured out a sequence yet to escape this yet; nor have i figured out what is going on.

has anyone else encountered this, and knows how to get out of it ? the only fix i've found is to ctrl-c and start a new mysql connection - and that's just not a proper fix.

+2  A: 

\d changes the statement delimiter.

You need to change it back to ;

But you can't end a statement until you type tablename

so try typing tablename followed by \d ;

Personally ctrl-c up-arrow enter seems easier. Especially since mysql still remembers your command history between sessions.

Byron Whitlock
+4  A: 

In MySQL, \d changes the query delimiter, which is normally ;. So you've actually changed your delimiter to items. For instance, try doing this:

\d items
desc items items
select 1 items

Fun times.

To change it back to semicolon, just do \d ;

wuputah