Add / Import .SQL file To MySQL Database Server

How do I import a MySQL .SQL text file to MySQL database sever using command line or gui tools?

You can import a MySQL script (or .sql) file into MySQL server using

  1. Unix / Linux shell prompt.
  2. phpMyAdmin web based gui tool.

Unix / Linux shell prompt example

Copy a .sql file to a remote server using sftp or scp client:
$ scp foo.sql
Login into a remote server using ssh client:
$ ssh
Type the following command to import a .sql file:


In this example, import a ‘foo.sql’ file into ‘bar’ database using vivek as username:

mysql -u vivek -p -h localhost bar < foo.sql


Login to phpMyAdmin. Open a web-browser and type phpMyAdmin url:
In phpMyAdmin, choose the database you intend to work with from the database menu list (located on the left side).

Fig.01: phpMyAdmin Database Selection

Choose the IMPORT tab > Click on Browse your computer “Choose file” > Select file > Choose Ok > Choose Go

Fig.02: phpMyAdmin Importing .SQL File

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts