Importing a Database Using MySQL
1. Prerequisites
Before importing a database, ensure that:
MySQL or MariaDB is installed and running.
You have access to the MySQL client (command-line tool).
You have a valid
.sqldump file (e.g.,database.sql).You have the necessary username and password to access the MySQL server.
The target database already exists (or you have permission to create one).
2. Command-Line Method
You can import a database directly from the Command Prompt or Terminal.
Step 1: Open Command Prompt
Navigate to the MySQL bin directory (if not already in PATH):
cd C:\xampp\mysql\binStep 2: Access MySQL
Login to MySQL using:
mysql -u root -pThen, enter your MySQL password when prompted.
Step 3: (Optional) Create a Database
If the target database doesn’t exist, create one:
Then exit MySQL:
Step 4: Import the .sql File
Run the import command:
Explanation:
-u root→ Username (root)-p→ Prompts for passwordfisheriesexp1→ Target database name<→ Tells MySQL to read from the SQL fileC:\Users\Administrator\Downloads\fisheriesexp.sql→ Path to your SQL dump file
3. Alternative: Using phpMyAdmin
If you’re using XAMPP, you can import databases visually via phpMyAdmin:
Start Apache and MySQL from XAMPP Control Panel.
Open your browser and visit:
Create a new database (if not exists).
Select the database → Go to Import tab.
Choose your
.sqlfile → Click Go.
Last updated
Was this helpful?