When you only need one table from a large MySQL/MariaDB dump, /go/table cuts it out. It reads the dump file, copies the statements for the table you name into a new .sql file, and can rename the table on the way. The command works on the text of the file only. It does not connect to a database, and it does not import anything. To load the result, import the new file yourself (see Examples). Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.
Quick start
/go/table -f /root/backup.sql -t wp_users
This creates /root/wp_users.sql.
Options
| Option | Required | Default | Notes |
|---|---|---|---|
-f <file> |
Yes | — | The SQL dump to read. It must be a plain .sql file, not compressed. |
-t <table> |
Yes | — | The table to extract. The name is case-sensitive and must match the dump. |
-o <file> |
No | /root/<table>.sql |
The file to create. An existing file is overwritten without a warning. |
-r <name> |
No | — | Renames the table in the new file. |
If -f or -t is missing, the command prints the usage line and exits with status 1.
Examples
# Extract wp_users to /root/wp_users.sql
/go/table -f /root/backup.sql -t wp_users
# Choose the output file
/go/table -f /root/backup.sql -t wp_users -o /tmp/wp_users.sql
# Extract the table and rename it
/go/table -f /root/backup.sql -t wp_users -r wp_users_copy
# Check that the file isn't empty, then import it into a database
ls -lh /root/wp_users.sql
mysql -u dbuser -p dbname < /root/wp_users.sql
Output
File /root/wp_users.sql created successfully.
| Outcome | What you get |
|---|---|
| File created | The message above. Exit status 0. |
-f or -t missing |
Usage: table [-f] SQL File Name [-t] Table Name [-o] Output File Name [-r] Rename Table (Optional). Exit status 1. |
| Dump file not found | File <file> does not exist. Exit status 1. |
| Unknown option | The usage line is printed, but the command carries on. |
[!WARNING]
The "created successfully" message does not mean the table was found. If the table name isn’t in the dump, the command creates an empty file and still prints the message. Check the size of the file.
Every run is logged to /var/log/go/table.log with a timestamp and the arguments used.
See the full reference at /go/table 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.
