MySQL Tutorial – A Beginner’s Guide

mysqlSQL stands for Structured Query Language, the type of language that people use to run databases, and MySQL is a relational database management system (RDBMS) based on SQL.

If you want to understand MySQL, you will need to begin by installing the program itself.  So, let’s jump right in to what you’ll need to do.

**Learn MySQL by completing a project – creating a blog!**

Installing MySQL

The way you install MySQL will depend on your operating system.  It is recommended that beginners look to the official MySQL developer site for instructions on how to install the program.

Windows users can find comprehensive installation guidelines from the MySQL Windows reference manual. You can choose to install from a MySQL installer or through an MSI package, and a configuration wizard is included.

Mac users should look to the Mac OS X reference manual.  It can be installed using the Native Packages Installer format, which requires administrator privileges, or through the tar package format, which does not.  The Mac OS X server comes with a version of MySQL already installed.

Linux users also have their own reference manual, which includes instructions on installing from a generic binary package, extracting and compiling from a source distribution, and using precompiled packages.

**Understand how to use MySQL for web app development with this online Udemy tutorial**

Once you have installed MySQL, you are ready to begin exploring the program.

Databases in MySQL

Databases consist of tables, which are collections of correlations between various items.  The following is a very simple table –

NameFavorite ColorFavorite Animal


The horizontal rows, sometimes called records, indicate particular values.  The vertical columns, sometimes called fields, indicate the particular categories that the values fall into.

**Find out how to use MySQL for dynamic website development with this online course**

MySQL is used to create much more complex tables than this, relationally linking them together.

You can now begin working with databases and MySQL functions.

Typing Commands into MySQL

You will use MySQL by typing commands into a command prompt, which should be something like a text box with ‘mysql>’ on the left-hand side, with a cursor blinking next to it.

To open this command prompt, find and open the MySQL Command Prompt program.  Depending on your operating system and version of MySQL, you may not have this program.  If not, you can open the MySQL client, type ‘mysql’ (without the quotes) and then press enter.

There are many commands used in MySQL, which you will need to look up and read about.  Let’s begin with a simple command that will display any databases.

Type the following into the command prompt and press enter.  Don’t forget the semi-colon at the end.

mysql> show databases;

You will see a short list of databases, such as ‘mysql’ and ‘test’.  Next, type the following to create a sample database named ‘sample.’

mysql> create database sample;

Now enter the first command again to show that the new database was indeed created.  You should see it in the list.

Next, we can add a bit of data to the database.  Enter the following command to indicate that you will be adding to the sample database.

mysql>  use sample;

Now we will create a table called Favorites to describe a person and his favorite things.  Begin by creating the table with the desired fields and types of values.

mysql> create table Favorites (Name text not null, Color text not null, Animal text not null);

The syntax here uses spaces to separate commands – in the parentheses, the first word (Name) indicates the name of the field, and the second word (text) indicates that it’s value will be a text object.  ‘Not null’ will prevent the table from allowing fields with no values.  The commas separate individual fields.

This will create a table like the one shown above, but without any data under the headings.  To populate the table with a row of data, use the following command.

mysql> insert into sample values('Ben','Green','Spaghetti');

Display your new table with the command –

mysql> select * from sample;

You should see a table like the one shown above, with the first row of data.

There are many more commands and syntax to learn, and the best way to learn what MySQL has to offer is to play with it’s functions as much as you can.

**New to coding?  Get a MySQL tutorial aimed at non-coders!**

What do you think a budding MySQL user should know about?  Tell us in the comments below!