Hi,

I use Ubuntu and want to restore a mysql file. How do i do it? It is on my desktop.

Thanks

Dani AI

Generated

Good — this was just a path problem. confirmed that adding the full home path fixed the restore, and was right to suggest using the command line. Two common, reliable ways to restore a .sql dump on Ubuntu are shell redirection and the mysql client's SOURCE command; the difference matters because the shell opens files for < while SOURCE is resolved by the mysql client itself.

Examples (adjust user, database and filename):

mysql -u root -p database_name < /home/ubuntu/Desktop/backup.sql
mysql -u root -p
mysql> USE database_name;
mysql> SOURCE /home/ubuntu/Desktop/backup.sql;

For compressed dumps:

gunzip -c /home/ubuntu/Desktop/backup.sql.gz | mysql -u root -p database_name

Quick troubleshooting checklist:

  • Confirm the file path and permissions: ls -l /home/ubuntu/Desktop/backup.sql. The user running the command must be able to read the file.
  • Make sure the MySQL server is running (systemd: sudo systemctl status mysql).
  • If the dump contains CREATE DATABASE/USE statements you can omit database_name; otherwise create the target DB first.
  • Watch the terminal for SQL errors; redirect output to a log if needed. For very large imports consider running inside screen/tmux and adjust max_allowed_packet if you see packet-related errors.

Cautions: restoring will overwrite tables if names collide — keep a backup of any existing data before importing.

Recommended Answers

All 2 Replies

Through the command line?

i didn't put /home/ubuntu before. Now it works.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.