You can import an SQL dump into a MySQL or MariaDB database from a terminal. Create the intended destination first and use an account with the required privileges.

Prepare the destination

On a hosting-panel server, create the database and user through the panel so ownership and mappings remain correct. On an independently managed database server, an authorised administrator can create a database using its SQL interface:

CREATE DATABASE destination_database;

The administrator must also grant the importing account the necessary privileges. Do not use the database root account merely because a tutorial does so. Check character set and collation requirements and compatibility between the dump and destination server.

Import the file

From the terminal, replace all placeholders:

mysql -u DATABASE_USER -p destination_database < backup.sql

MariaDB installations may provide the client as mariadb instead of mysql. Enter the password at the prompt.

The dump can contain statements that select another database, drop tables or replace data. Inspect it and back up any existing destination first. Use a private file location, not a publicly accessible web directory.

Check the result

Confirm the client reports no error, inspect the expected tables and test the application. A partly completed import is not proof that the whole database restored correctly; investigate any failure before rerunning it over existing data.