Tuesday, 02 Apr, 2024 -468

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: 2170
img
02 Apr, 2024 view: 1029
img
01 Apr, 2024 view: 807
img
01 Nov, 2023 view: 748
img
02 Apr, 2024 view: 481
img
26 Apr, 2024 view: 477
img
01 Apr, 2024 view: 327
img
09 Apr, 2024 view: 251
img
18 Apr, 2024 view: 243
img
16 Mar, 2025 view: 28
Trending