This is useful if you don’t have access to phpmyadmin on your server but have access to ssh and ftp. Or you have a huge sql dump like 10MB or higher that you cannot import directly on phpmyadmin. In my case the phpmyadmin directory was password protected by Apache and I don’t have the right password.

First upload the .sql file on your server using an FTP client and remember the path.

For Linux

for Windows

Login to your server using an SSH client like Putty.

On the command line access MySQL
$> mysql -u username -p password

replace username and password with yours.

On the MySQL client command line access and use your database.
$> use lopaudb;

Now to import your dump;
$> source /home/lopau/mydump.sql;

If successful you should see
Query OK, 13 rows affected (0.00 sec)

That easy.

One response to “Import sql dump using the MySQL client”

  1. Lysender says:

    Wow! I didn’t know that source command yet. Gotta try this new one.

    All I know is:

    mysql -D db_name -u user_name -p < my_dump.sql

Leave a Reply

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