DatabaseManagementSystems/Practical
2024-11-10 21:31:52 +05:30
..
Assignment-A2 Added updated database_a2 file. 2024-11-01 02:25:10 +05:30
Assignment-A3 Added title in queries-a3 file. 2024-10-28 13:31:32 +05:30
Assignment-A4+A5 Added missing semicolon in example. Thanks to Narinder for pointing it out 🙇 2024-11-09 00:33:04 +05:30
Assignment-A6 Simplified and improved queries for A6. 2024-11-02 20:35:43 +05:30
Assignment-A7 Moved old Queries-A6 to Queries-A7 since it's the cursor assignment. 2024-10-28 13:40:40 +05:30
Assignment-A8 Moved Queries-A7 to Queries-A8 since A8 is the library/trigger one. Again, thanks to Shivani for pointing it out. 2024-10-28 13:42:20 +05:30
Assignment-A9+B4+C1 (Mini Project) added connectivity content 2024-10-21 23:14:03 +05:30
Assignment-B1 Fixed some questions to match the queries. 2024-10-17 20:27:09 +05:30
Assignment-B2 Fixed query 2 2024-11-09 17:25:42 +05:30
Assignment-B3 Added queries and softcopy for B3. 2024-10-17 20:45:34 +05:30
Practical Exam updated readme.md 2024-11-10 21:31:52 +05:30
README.md Fixed links 2024-07-25 13:36:46 +05:30

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

  1. 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.

  2. After downloading the file, locate it in the Files app. The downloaded file will mostly likely be preset in the Downloads folder.

  3. Right click in a empty space in the Files app window, and click on Open in Terminal (or something along those lines).

  4. Now, start mysql

sudo mysql -u root -p
  1. 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.

  1. 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.

  1. First download the Database_A2.sql file.

  2. Locate the file in Files app, mostly likely present in the Downloads folder.

  3. Right click in an empty space in the Files app window and click Open in Terminal.

  4. Start mysql: sudo mysql -u root -p

  5. Create an empty database: CREATE DATABASE Database_A2

  6. Exit from mysql: exit

  7. Lastly, import the file: sudo mysql -u root -p Database_A2 < Database_A2.sql

  8. That's it! Your database has been imported in MySQL.