Ubuntu: Terminal command repeated twice to work



Question:

I am very new with linux and ubuntu. Installed it in VMWare Player yesterday and I've been watching some good command tutorials.

I've installed mysql and php and some stuff.

I've created a database and a table and been trying to play around a bit with the command and such. Now I noticed that I must enter a command twice to it to work, the first time I use it, it triggers an error. (This is only in the mysql area)

Check this out:

First i tried:

mysql> \G use my_database  ERROR:   No query specified  

Then I tried it again:

-> \G use my_database  Query OK, 0 rows affected (0.00 sec)  

Why is this happening? Is it a bug? Or are there some reasons for this behavior?


Solution:1

What is the reason to use \G in front of your command/query?!? Used like this, it is normal to get this error: No query specified, because you didn't specified any query before to use \G:

mysql> help  ...  ego       (\G) Send command to mysql server, display result vertically.  ...  

The right way to switch to my_database from command-lie is:

mysql> use my_database;  

or (see help again):

mysql> \u my_database  

Also, when you switch to another database, I don't see any reason to use \G, since the output will be the same. but if you really want it, you can use after you typed your command/query, like this:

mysql> use my_database \G  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »