MySQL: How to install a test database and confirm the installation

Now that I have installed PHP and MySQL:

How to install PHP/MySQL and confirm the installation

I wanted to start using MySQL so I searched for a sample database full of data that I could install for testing. I found this “Employee Sample Database” on the dev.mysql.com website:
https://dev.mysql.com/doc/employee/en/

The instructions for installation:
https://dev.mysql.com/doc/employee/en/employees-installation.html

led me to a github repository where I could download the database:
https://github.com/datacharmer/test_db

To download the database on this page, click the green “Clone or download” button, then choose “Download ZIP”.

Once downloaded, I moved and unzipped the file to a folder MySQL folder on my desktop which I called “employees_sample_db”. Inside this folder is a file called employees.sql, which is critical for the install.

The next step is to open a command window and cd to the directory where the sample database is stored.

Caution: If you use a short command that doesn’t specify the user or trigger a password, such as:

mysql < employees.sql

then you will get an error that looks like this:

This is because you didn’t select a user with the -u flag (so Microsoft defaulted the user to ‘ODBC’ for some reason), and you didn’t trigger password collection with -p.

To avoid this error, we will use this command to install the database:

mysql -u root -p < employees.sql

which means install the sample database under user ‘root’ and ask for root’s password for the command.

To see a list of possible users and double check or reset their passwords, I opened Bitnami’s WAMP Stack Manager app and clicked the “Open phpMyAdmin” button:

This launches the phpMyAdmin tool which is for managing MySQL databases and running SQL queries:

To see a list of user accounts and manage permissions and passwords, click the “User accounts” link at the top. There will be a table that looks like this:

Now going back to the command line, after you enter the password when prompted, you should see something like this which indicates the mysql database being loaded:

Then we can use this command to test the database installation:

mysql -t < test_employees_md5.sql

which yields:

Finally, we can use the SQL dialog in the phpMyAdmin utility to query against the new database. The first query I would run is:

SHOW DATABASES;

which yields:

Then I used these SQL commands, (in order):

USE employees;
SELECT * from employees;

SELECT * from employees where first_name like "Berni";