Ffile2fix
Sign in Get started

What is a .sql file?

A .sql file is a plain-text script of SQL statements, most often a database backup created by mysqldump, pg_dump or phpMyAdmin. It contains CREATE TABLE and INSERT statements that rebuild the database when imported.

Key facts

  • Plain text, often UTF-8; dumps range from a few KB to many GB and are frequently compressed as .sql.gz.
  • MIME type is application/sql (RFC 6922), though servers often send text/plain.
  • SQL dialects differ: a MySQL dump with backtick quoting and ENGINE=InnoDB will not import into PostgreSQL or SQLite unchanged.
  • Dumps can contain DEFINER clauses, SET statements and comments like /*!40101 ... */ that only MySQL-compatible servers understand.
  • Created by mysqldump, pg_dump, phpMyAdmin, Adminer, WordPress backup plugins and hosting control panels.

How to open a .sql file

Windows

View it in VS Code or Notepad++ (large dumps open better in a dedicated large-file editor). Import it with MySQL Workbench, HeidiSQL or mysql -u user -p dbname < dump.sql.

macOS

Open it in a code editor, or import with TablePlus, Sequel Ace or mysql -u user -p dbname < dump.sql in Terminal.

Linux

Inspect it with less dump.sql, import into MySQL/MariaDB with mysql -u user -p dbname < dump.sql, or into PostgreSQL with psql -d dbname -f dump.sql.

Common problems and fixes

"ERROR 1064 (42000): You have an error in your SQL syntax"
The statement uses syntax your server version or dialect does not support, or the file is truncated. Go to the reported line and compare it with your server version; reserved words used as names need backticks.
"Unknown collation: 'utf8mb4_0900_ai_ci'"
The dump came from MySQL 8 and you are importing into MariaDB or MySQL 5.7. Replace utf8mb4_0900_ai_ci with utf8mb4_unicode_ci throughout the file and import again.
"MySQL server has gone away" or packet too large
A single INSERT is bigger than max_allowed_packet. Raise max_allowed_packet on the server (and the client with --max_allowed_packet=512M), or import from the command line instead of phpMyAdmin.
phpMyAdmin import times out or rejects the file size
Upload limits come from upload_max_filesize, post_max_size and max_execution_time. Compress the file to .sql.gz, raise those limits, or import with the mysql command line.
"Access denied; you need SUPER privilege" because of DEFINER
Views, triggers or routines are tied to a user that does not exist on the new host. Remove or change the DEFINER=`user`@`host` clauses before importing.

Often converted to or from: CSV, SQLite database, JSON, PostgreSQL dump

Frequently asked questions

How do I open a .sql file?

It is plain text, so any code editor can show it. To use the data you must import it into a database server such as MySQL, MariaDB or PostgreSQL.

Can I search and replace URLs in a WordPress SQL dump?

Simple text replacement breaks PHP serialized data when the length of a string changes. Use a serialization-aware tool such as WP-CLI's wp search-replace on the live database, or check serialized values carefully.

How do I import a very large .sql file?

Use the command line, for example mysql -u user -p dbname < dump.sql, which avoids web upload and timeout limits. Compressed dumps can be streamed with gunzip < dump.sql.gz | mysql -u user -p dbname.

See all file types β†’ Β· Browse error fixes β†’