.. | ||
Assignment-A2 | ||
Assignment-A3 | ||
Assignment-A4+A5 | ||
Assignment-A6 | ||
Assignment-A7 | ||
Assignment-A8 | ||
Assignment-A9+B4+C1 (Mini Project) | ||
Assignment-B1 | ||
Assignment-B2 | ||
Assignment-B3 | ||
Practical Exam | ||
README.md |
How to import database in MySQL
This is a guide for importing a database in MySQL using the terminal.
Prerequisites
- Have MySQL installed on your machine.
Guide
-
Download the database file from this repository. These database files have
.sql
extension and can be found in the Assignment folders within the Practical folder. -
After downloading the file, locate it in the
Files
app. The downloaded file will mostly likely be preset in the Downloads folder. -
Right click in a empty space in the
Files
app window, and click onOpen in Terminal
(or something along those lines). -
Now, start
mysql
sudo mysql -u root -p
- Create an empty database & exit:
CREATE DATABASE database_name;
exit
database_name
is the name of your database in which all the tables, data, etc. will be imported.
- Lastly, import the database from
database.sql
file:
sudo mysql -u root -p database_name < database.sql
Example
Let's consider I want to import the database for Assignment-A2. The database file is present in Practical/Assignment-A2 folder.
-
First download the Database_A2.sql file.
-
Locate the file in
Files
app, mostly likely present in the Downloads folder. -
Right click in an empty space in the Files app window and click Open in Terminal.
-
Start mysql:
sudo mysql -u root -p
-
Create an empty database:
CREATE DATABASE Database_A2
-
Exit from mysql:
exit
-
Lastly, import the file:
sudo mysql -u root -p Database_A2 < Database_A2.sql
-
That's it! Your database has been imported in MySQL.