Tuesday, 02 Apr, 2024 -504

How to Import a MySQL Database using Command Line

This tutorial will show you how to use the Command line to import a MySQL database. To import an existing file into MySQL, you will need to create a new database. This is where the SQL file's contents will be imported.

first time login your mysql .

Here Command :   
1.login: sudo mysql -u username -p password
   2.Create Database :  Use this command to create a database after logging into MySQL. Make a database. TYPE OF DATABASE;
   3. After create database than enter  your db using this command . Use Your DATABASE NAME;
   4. After Entry database than use this command and import database. source path ; [ example source /var/html/db.sql  ]
   5.Or this command mysql -u username -p db_name < file.sql

  * username : Username with which you connect to the database

 *db_name: The just formed database's name

  The SQL file to import, *file.sql, is in the current directory.

Tags
Most Popular
img
02 Apr, 2024 view: 2241
img
02 Apr, 2024 view: 1101
img
01 Apr, 2024 view: 877
img
01 Nov, 2023 view: 815
img
26 Apr, 2024 view: 518
img
02 Apr, 2024 view: 517
img
01 Apr, 2024 view: 362
img
09 Apr, 2024 view: 288
img
18 Apr, 2024 view: 281
img
16 Mar, 2025 view: 70
Trending