DEV Community

Cover image for MYSQL FOR BEGINNERS! - PART ONE
skino
skino

Posted on

MYSQL FOR BEGINNERS! - PART ONE

Intro
MySQL is a huge part of the data world and often people are scared to get started, because they don't know how, where or what to start with.

Before start the tutorial you will need to install MySQL Server on your machine along with MySQL Client for writing SQL.

I'll write out the steps for Ubuntu Users, if your not using Ubuntu you will need to google the setup steps.

First off: Update your OS.
No start of a project is complete without an apt update :)

sudo apt update && sudo apt upgrade
Enter fullscreen mode Exit fullscreen mode

This ensures your repo's are all up to date.

Install MySQL
On Ubuntu this is dead easy, no crazy warren of pages to find the right download.

sudo apt install mysql-server
Enter fullscreen mode Exit fullscreen mode

Accept any of the prompts about disk space and continue.

Next you need to run the secure installer.

sudo mysql_secure_installation
Enter fullscreen mode Exit fullscreen mode

Type y for all of the questions you get until it asks what level of security you want, then type 0 for the lowest settings of security.

Note: This really doesn't matter as its a local test DB, if it was live we would need to use more secure passwords.

And thats it.... MySQL is installed.

Now onto the MySQL Client

Install Dbeaver CE
DbeaverCE is a free open source Database management tool. I used to use a tool called DB Visualiser but this was a premium tool (over £100) and to be honest didn't give enough of a benefit over a free version so now i use either Jetbrains DataGrip or Dbeaver.

to install simple type the following in your terminal.

sudo snap install dbeaver-ce
Enter fullscreen mode Exit fullscreen mode

Done! Its now installed and you can open it from the applications menu!

Now onto Sample Database.

Employee Database installation
MySQL link to a few Example DB's but i quite like the Employee one for getting started with.

To install simply open up a terminal and cd to a location you're happy with like Documents. When there type the following into the terminal:

git clone https://github.com/datacharmer/test_db.git
Enter fullscreen mode Exit fullscreen mode

Now cd into this directory...

cd test_db/
Enter fullscreen mode Exit fullscreen mode

Once in this directory type the following in the terminal:

mysql < employees.sql
Enter fullscreen mode Exit fullscreen mode

You should then see the below.

SQL Import screenshot

Conclusion
In this post we have looked at VERY basic database requests, next post we shall bring in another table and also SELECT aliasing.

If you found this post useful please consider following me on twitter @skino2020 for future updates to this series and if you found it really helpful consider buying me a coffee here.

Top comments (0)