/go/import loads a .sql dump file into a database that already exists. It: Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.
Quick start
# 1. Create the empty database
mariadb -e "CREATE DATABASE example_db"
# 2. Import the dump
/go/import /root/backup.sql example_db
Arguments
| Position | Argument | Required | Notes |
|---|---|---|---|
| 1 | file |
Yes | Path to a plain-text .sql dump. Compressed files (.gz, .zip) are not supported. |
| 2 | database |
Yes | The name of an existing database. It is not created for you. |
Neither argument is checked. A wrong path or database name does not produce an error message.
Dump requirements
What the command does depends on what the dump contains.
| Dump contains | Result |
|---|---|
DROP TABLE and CREATE TABLE (the mysqldump default) |
Works like a normal import. The dump’s own table definitions replace the placeholders. |
INSERT statements with column names, and no CREATE TABLE |
The intended use. Placeholder tables are built from the column names. |
INSERT statements without column names, and no CREATE TABLE |
Fails silently. The placeholder table has one column, which does not fit the rows. |
CREATE TABLE without a matching DROP TABLE (or CREATE TABLE IF NOT EXISTS) |
The placeholder table is kept and the dump’s definition is skipped, so the table keeps the placeholder structure. |
To get column names in INSERT statements, export with mysqldump --complete-insert.
Placeholder tables
| Part | What is created |
|---|---|
| First column | INT AUTO_INCREMENT PRIMARY KEY |
| Every other column | TEXT |
Original data types, lengths, defaults, indexes, and keys are not rebuilt. Strings, dates, and decimals end up as text, and a first column that is not an integer key does not fit.
Examples
# Create the database, then import into it
mariadb -e "CREATE DATABASE example_db"
/go/import /root/backup.sql example_db
# Check the result: list databases and sizes
/go/dbls
# Check the result: count rows in one table
mariadb -e "SELECT COUNT(*) FROM example_db.wp_posts"
# See the real errors by importing by hand (not silenced)
mariadb --force example_db < /root/backup.sql
# Decompress first if the dump is compressed
gunzip /root/backup.sql.gz
/go/import /root/backup.sql example_db
Output
| Stage | What you see |
|---|---|
| Table check | One line that updates in place: [<number>/<total>] Checking Table <table> |
| Import | A pv progress bar with size, time, speed, and percentage |
| Finish | Nothing. There is no summary and no error report. |
See the full reference at /go/import and the GoAdmio command index.
GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.
