---
title: How to Import a Large MySQL Database over SSH
description: "**In short:** To import a large database over SSH: upload the .sql file to the server, create a database and a user (CREATE DATABASE, CREATE USER, GRANT ALL PRIVILEGES), then run mysql -u USER -p DBNAME < file.sql and enter…"
url: "https://www.hyyat.com/en/knowledgebase/import-mysql-database-ssh/"
updated: "2026-09-30"
category: Server management / servers without control panel
---

# How to Import a Large MySQL Database over SSH

**In short:** To import a large database over SSH: upload the .sql file to the server, create a database and a user (CREATE DATABASE, CREATE USER, GRANT ALL PRIVILEGES), then run mysql -u USER -p DBNAME < file.sql and enter the password. This is faster than phpMyAdmin for large files.

Large databases are hard to import through phpMyAdmin because of upload size and time limits. On a server without a control panel you also need the command line. Here is how to import a database over SSH.

**1.** Connect to your server over SSH (see [how to connect to your server over SSH](https://www.hyyat.com/en/knowledgebase/how-to-connect-to-a-server-via-ssh/)).

**2.** Upload your .sql file to the server, for example with SFTP.

**3.** Create an empty database and a user, and give the user privileges on it. Log in as root and enter the MySQL root password:

```
mysql -u root -p
```

```
CREATE DATABASE hyyat;
CREATE USER 'hyyat'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON hyyat.* TO 'hyyat'@'localhost';
FLUSH PRIVILEGES;
exit
```

Here the database and user are both named hyyat. Use your own names and a strong password.

**4.** Go to the folder with your .sql file and import it:

```
mysql -u hyyat -p hyyat < hyyat123.sql
```

Enter the user's password when asked, and wait until the command finishes. The -p option without a value asks for the password, so it does not appear in your shell history.

See also [basic MySQL commands over SSH](https://www.hyyat.com/en/knowledgebase/mysql-commands-ssh/) and [how to import and export a database with phpMyAdmin](https://www.hyyat.com/en/knowledgebase/import-export-mysql-database-phpmyadmin/).

**Related service:** [Hyyat Host server management](https://www.hyyat.com/en/server-management/) can migrate and import large databases for you, with 24/7 support.

 **Need this service from Hyyat Host?**Our team handles it for you, with support replying to tickets within 24 hours at most.[Server Management](https://www.hyyat.com/en/server-management/)[dedicated server](https://www.hyyat.com/en/dedicated-server/)
