Showing entries 1 to 2
Displaying posts with tag: command (reset)
How to execute mysql query from a file in your mysql client terminal?

Being a terminal fan myself, I usually find myself running queries in the mysql client instead of a UI interface as it is much faster. You get to see the results instantaneously.

One thing which is pretty tedious is editing a big query again after once running it as the whole multi-line formatted query now appears on a single line, thus reducing its readability.

But no problems, you can edit your query from a file and run the file from your mysql client terminal as many times as you want with as many edits.

To do so, follow the below steps:

1. Open your terminal and cd into the folder you want to store our sample mysql file. Then save your query in a sample file called my_query.sql

$ cd /path/to/folder
$ vim my_query.sql

Save a sample query like:

SELECT * FROM employees

[Read more]
MySQL Command Line Help

I tend to use MySQL from the interactive command line shell quite a bit (SSH to your db server and type the command mysql to start). I noticed today that there is a pretty extensive built in help system in this command.

You can access it by typing help COMMAND, so for instance if you type help ALTER TABLE you get a quick reference for constructing an ALTER TABLE statement.

If you can't remember what command you want to use, then typing help contents is your friend. It will output:

For more information, type 'help item', where item is
one of the following categories:
Column Types
Data Definition
Data Manipulation
Geographic features

So if your looking for that command that outputs all the columns in a table, but don't know what it's called, you might now try help administration

[Read more]
Showing entries 1 to 2