MySQL

MySQL

Maybe you've been studying SQL for some time now and have mastered all the commands and syntax. What next? The knowledge you gained will quickly disappear if you don't have a way to practice on meaningful data. 

Most tutorials use sample data and simple problems (such as finding employee salaries). While they are good to learn basics, honing your skill further requires practice on real-world datasets.

For this reason, you can install MySQL on your machine and upload datasets from CSV files to local server. You can then run SQL commands on this dataset.

Installing MySQL

To install MySQL, you can visit the official site (https://dev.mysql.com/doc/mysql-getting-started/en/) and follow the instructions as per your machine (Windows/Mac). 

You can download step-by-step guide on setting up MySQL server by clicking on the "Download MySQL setup guide" below.

Basic Operations with MySQL

SHOW Databases;

CREATE Database temp_db;

USE temp_db;

CREATE Table test_table

(

id int not null auto_increment,

name varchar(255) not null,

birth_date date,

primary key (id)

)

;

SHOW Tables;

DESCRIBE test_table;

INSERT INTO test_table ( name, birth_date) VALUES

  ( 'Amar', '2015-01-03' ),

  ( 'Akbar', '2013-11-13' ),

  ( 'Anthony', '2016-05-21' )

;

Select * from test_table limit 10;

Select * from test_table WHERE name = 'Amar';

Delete from test_table where name = 'Anthony';

Drop test_table


Loading Data from CSV file to MySQL table using Command Line Interface

3. Load data using the following commands:

4. If you get an error as "The MySQL server is running with the --secure-file-priv option so it cannot execute this statement", then try placing your .csv file in the following location and upload it from there: C:\ProgramData\MySQL\MySQL Server 8.0\Uploads

Check this documentation from MySQL: https://dev.mysql.com/doc/refman/8.0/en/loading-tables.html



Loading Data from CSV file to MySQL table using MySQL Workbench

Frequently Asked Questions (FAQs)

How to install MySQL on local computer?

One can find detailed instructions on installing MySQL at this link: https://dev.mysql.com/doc/mysql-getting-started/en/.

Having visual studio 2015,2017 or 2019 is a requirement for MySQL installation. If its not present on your machine already, then you may have to download and install it first. You can download visual studio from this link: https://visualstudio.microsoft.com/. Select 2019 version.

What is the Difference between mysql-installer-web-community and mysql-installer-community?

Both type of installations can result in the same final product. The "web-community" version does not come pre-bundled with any MySQL applications but instead downloads the individual products chosen during installation. The "web-community" is online installer, i.e. one needs to connect to the online server and installations files get downloaded during installation. The non-web standard version is an offline installer and comes pre-loaded with full features and products. This is also the reason that the standard non-web version is larger in size than the web-version, but installed files might take approximately the same space if you install all the products/features.