Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install a .sql file using MySQL Command line Client

I need to install or import a .sql file into an empty database that I've created. The .sql file will install all the tables etc.

When I click MySQL Command line Client prompt, I add my credentials and then...(to install / import the .sql file)?

Thanks guys!!

like image 871
Reflex84 Avatar asked Jan 16 '12 16:01

Reflex84


People also ask

How do I run a .SQL file from MySQL command line?

use the MySQL command line client: mysql -h hostname -u user database < path/to/test. sql. Install the MySQL GUI tools and open your SQL file, then execute it.

How do I install SQL command line client?

To install MySQL Shell on Microsoft Windows using the MSI Installer, do the following: Download the Windows (x86, 64-bit), MSI Installer package from http://dev.mysql.com/downloads/shell/. When prompted, click Run. Follow the steps in the Setup Wizard.


2 Answers

Something like this:

shell> mysql db_name < script.sql

...specify your options: --user, --password, --host, --port...

More information - mysql — The MySQL Command-Line Tool.

like image 199
Devart Avatar answered Oct 20 '22 01:10

Devart


From the MySql prompt, type:

\. file_name.sql 
like image 37
paulsm4 Avatar answered Oct 20 '22 01:10

paulsm4