Ben Emson

Everyday MySQL Commands

I'm trying to put together a number of blog articles and many of them use the MySQL database, so I figured that I would post up some of my most used everyday MySQL SQL commands. Most likely I will append further commands as I write more articles so this is page is really a work in progress.

I've also assumed that you want to have full rights when executing these commands so I've used sudo, however you may not need this depending on your set up.

Finally if some other web site covers the command better or I'm feeling lazy I'll just pop it in the links list at the bottom of this page.

Useful MySQL Commands

Starting MySQL Demon

Start your MySQL database and get it running as a background process: Liquid error: No such file or directory - posix_spawnp

MySQL create databases script

Make a SQL script that creates 3 databases and assigns all rights to my username. Copy the following SQL and paste it into a file called create_databases.sql: Liquid error: No such file or directory - posix_spawnp

MySQL drop databases script

Make a script to drop databases. Copy the following SQL and paste it into a file called drop_databases.sql: Liquid error: No such file or directory - posix_spawnp

Executing a script from MySQL

The above scripts can be executed from the command-line with the either of these commands: Liquid error: No such file or directory - posix_spawnp

Showing MySQL databases

To check that the databases were created : Liquid error: No such file or directory - posix_spawnp

Displaying database tables

Displaying the tables of a database: Liquid error: No such file or directory - posix_spawnp

Displaying details about a database table

Displaying details about a particular database table: Liquid error: No such file or directory - posix_spawnp

Droping a database table

Dropping a table from a database: Liquid error: No such file or directory - posix_spawnp

Displaying information about a table

Displaying the fields and field metadata about a table: Liquid error: No such file or directory - posix_spawnp

Useful Links

These are just a few quick and simple MySQL commands that you will always use. Hope this helps.

blog comments powered by Disqus