Skip to content
Advertisement

How do i create a MYSQL database locally using Database folder downloaded from github

I know the above question is incomplete. Let me explain this in brief. I downloaded the repository from this github link https://github.com/datacharmer/test_db and as per instructions on readme file i tried to create a database locally but i got syntax error when i ran a command mysql < employees.sql . I tried from both windows cli and MYSQL clc. Can someone help me to create a mysql database using above github data. Thanks in advance

Advertisement

Answer

The SQL queries in that repository are quite destructive, many starting with a DROP DATABASE, which can bite you if you’re not paying attention.

Do yourself a favour and create the databases manually. Look at the .sql files and you will see the CREATE DATABASE and CREATE TABLE statements. Run them one by one. This will help you become accustomed to how to create databases and tables in MySQL.

At the bottom of the .sql files, you’ll see lines that look like this:

SELECT 'LOADING departments' as 'INFO';
source load_departments.dump ;

What you are interested in is the file name that comes after source. Open those files and you will see the INSERT statements that populate the tables you created in the previous step. This will help you become accustomed to inserting records into your tables.

Once this is done, you will have a new database with tables and data for you to work with. Do not trust just any SQL or bash script with the contents of your database. Ever.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement