Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
VGSources
Blog

How to Import a MySQL Database Dump and Fix Common Import Errors

Use the right mysql command for self-selecting and single-database dumps, then troubleshoot credentials, database selection, syntax, encoding, PowerShell, and max_allowed_packet failures.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The standard restore command is mysql db_name < dump.sql when the SQL file contains table and data statements for one database. If the dump was created with --all-databases or --databases and includes its own CREATE DATABASE and USE statements, run mysql < dump.sql instead. The correct command depends on what is inside the file, the account you use, your shell, character encoding, and the source and target MySQL versions.

This guide shows how to identify the dump, import it safely, handle Windows PowerShell, and resolve the common 1044, 1045, 1046, 1049, 1050, 1064, 1149, 1153, 2006, and 2013 errors.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What you need before importing

Have the SQL file, a reachable MySQL server, and an account allowed to perform every operation represented in the dump. A normal SQL dump is text containing statements such as CREATE TABLE, INSERT, views, triggers, routines, and database-selection commands. It is not the same as a physical tablespace copy or another backup format; those require a different restoration procedure.

  • Know the file path and confirm that it is an SQL-format dump.
  • Know the target server host and port if they are not the local defaults.
  • Have the intended MySQL username and password. Use the password prompt rather than putting a plaintext password in shell history.
  • Confirm that the account has the object-creation and other privileges required by the statements in the file.
  • Check the source and target MySQL versions, SQL mode, character set, and whether a clean target database or downtime is acceptable.
  • Estimate the dump size and identify unusually large rows or statements before changing packet limits.

Determine whether the dump creates and selects a database

Open the beginning of the file in a text editor or inspect it with a command-line viewer. Look for CREATE DATABASE and USE. A dump generated with --all-databases or --databases normally contains database-selection information and can be fed directly to the client. A single-database dump made without --databases commonly contains tables and data but no target-database creation or selection.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
Dump contents Typical command What must already exist
Multiple databases or a dump that includes CREATE DATABASE and USE mysql < dump.sql The account must be able to create or use the databases named in the file.
One database with no database-selection statements mysql db1 < dump.sql db1 must exist, and the account must be allowed to use it.
One database that has not yet been created mysqladmin create db1, then mysql db1 < dump.sql The account used for creation needs the appropriate database-creation privilege.

Do not assume the filename tells you which case applies. A file called backup.sql can contain many databases, while a file exported from one schema can omit every CREATE DATABASE statement.

Import from a terminal

Import a dump that selects its own databases

For a dump created with --all-databases or --databases, run:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mysql -u user -p < dump.sql

The client asks for the password interactively. Add -h host and -P port when the server is remote or listens on a nondefault port:

mysql -h db.example.net -P 3306 -u user -p < dump.sql

The client executes the file in order. If a statement fails, read the first reported error and line number before rerunning; later errors can simply be consequences of the first failure.

Import a single-database dump into an existing database

When the file does not contain CREATE DATABASE and USE, specify the default database on the command line:

mysql -u user -p db1 < dump.sql

The database name is placed after the connection options and before the redirection operator. Supplying it prevents the 1046 “no database selected” failure.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Create the target database first

If the target does not exist, create it and then import:

mysqladmin -u user -p create db1
mysql -u user -p db1 < dump.sql

Alternatively, connect interactively and create it with SQL:

mysql -u user -p
CREATE DATABASE IF NOT EXISTS db1;
USE db1;
source dump.sql;

The source command is a command of the interactive mysql client, not ordinary SQL sent to the server. Give it the correct path if the file is not in the current directory.

Specify the connection character set

If the dump contains non-ASCII text, choose the character set explicitly:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mysql --default-character-set=utf8mb4 -u user -p db1 < dump.sql

The client ignores a Unicode byte-order mark at the start of input, but the mark does not change the connection character set. Setting utf8mb4 (or the character set required by the dump) makes the client-server interpretation explicit.

Importing from Windows PowerShell

PowerShell reserves the < operator, so a command copied from a Unix shell may fail before MySQL receives any input. Use a compatible shell for the redirection:

cmd.exe /c "mysql -u user -p db1 < dump.sql"

You can also open Command Prompt, change to the directory containing the file, and run the ordinary mysql db1 < dump.sql command there. Keep the password interactive rather than adding it to the command line.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Avoid UTF-16 dump files created by PowerShell

PowerShell redirection can create UTF-16 output. MySQL cannot load that output as a connection character set in the usual import path. When creating a dump on Windows, have mysqldump write the file itself:

mysqldump -u user -p db1 --result-file=dump.sql

Using --result-file avoids PowerShell’s text-redirection encoding conversion. If a file has already been produced through redirection, recreate it with this option or convert it deliberately to a compatible encoding before importing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Privileges, hosts, and authentication

Authentication and authorization are separate checks. The server must first accept the username, password, and connection origin; it must then allow that account to use the named database and execute the statements in the dump. Verify the exact host, port, username, and account grants before editing the SQL file.

Test the login independently:

mysql -h host -P port -u user -p

After connecting, check that the account can see and use the intended database. If the dump creates databases, tables, views, triggers, routines, or users, the account needs the corresponding privileges. A successful login alone does not guarantee a successful restore.

Common import errors and their fixes

Error Meaning Action
1044 access denied for the database The account connected, but it is not allowed to access the named database. Check the database name, connection host, and grants. Use an account authorized for that database or have an administrator grant the required privileges.
1045 access denied for user Authentication failed or the supplied password was rejected. Recheck -u, -p, host, and port. Connect again with the intended account and enter its password at the prompt.
1046 no database selected The statements need a default database, but none was selected. Run mysql db1 < dump.sql or add USE db1; before sourcing the file.
1049 unknown database The named database does not exist or is misspelled. Create it with mysqladmin create db1 or CREATE DATABASE, or correct the database name and rerun.
1050 table already exists The dump is replaying CREATE TABLE for a table that is already present. Decide whether to restore into a clean database, preserve the existing table, or use a dump containing appropriate drop statements. Take a backup before destructive changes.
1064 or 1149 SQL syntax error The server could not parse a statement. Read the reported line, inspect nearby SQL, and compare source and target MySQL versions, SQL mode, reserved words, and character sets. Repair the specific statement; there is no universal edit for these errors.
1153 packet too large A statement, row, or binary-log event exceeded max_allowed_packet. Check both the client and server limits, increase them only as needed, apply the server configuration, and retry.
2006 MySQL server has gone away The connection was closed during processing, commonly because of a packet, timeout, or server-side failure. Check the server log and packet size, then verify that the server remained running and retry after correcting the underlying limit or failure.
2013 lost connection to MySQL server during query The connection dropped while a statement was executing. Investigate packet limits, server availability, timeouts, and the failing statement. A large insert can produce the same packet-related symptom as 1153.

Fixing access-denied errors (1044 and 1045)

Start with a clean connection test rather than repeatedly importing. Run:

mysql -h host -P port -u user -p

Check for typographical errors in the username, host, port, and database name. MySQL accounts are matched with a user and connection host, so an account that works locally may not be authorized from a remote host. Ask an administrator to inspect the account’s grants if you cannot do so yourself.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

For 1045, the password was not accepted or the account could not authenticate. For 1044, authentication succeeded but access to the named database was denied. Do not “fix” either error by embedding a password in a script or shell history; use the prompt or another protected credential mechanism.

Fixing database-selection errors (1046 and 1049)

Open the dump and determine whether it contains a USE statement. If it does not, put the target database in the command:

mysql -u user -p db1 < dump.sql

If the command reports 1049, the database name is absent, misspelled, or not present on that server. Create it, then rerun the import:

mysqladmin -u user -p create db1

When creating it manually, use:

CREATE DATABASE IF NOT EXISTS db1;

Do not create a second database merely to hide a spelling error. Confirm the exact name expected by the application and by the dump.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Fixing “table already exists” (1050)

First decide what the restore is meant to accomplish. A replacement restore should normally use a separate, empty target so that old rows and objects cannot be mistaken for restored data. If the existing database must be retained, take a backup and inspect the conflicting table before choosing a merge or overwrite strategy.

Do not blindly add DROP TABLE statements to an important production dump. Dropping objects is destructive and can affect dependent views, triggers, routines, and application availability. A clean database is often the safest way to test whether the dump itself is complete.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Diagnosing SQL syntax errors (1064 and 1149)

Capture the exact statement and line reported by the client. The error may be caused by a version difference, a reserved word used as an identifier, an incompatible SQL mode, a character-set declaration, or a damaged or manually edited line. Compare the source server’s MySQL version and settings with the target before changing the file.

  1. Locate the reported line in the dump and read the complete statement, including preceding comments and delimiters.
  2. Check whether the statement uses syntax supported by the target MySQL version.
  3. Check identifiers against reserved words and verify quoting.
  4. Check the active SQL mode and character set on the target.
  5. Test a corrected copy in a disposable database before applying any change to the real target.

Because 1064 and 1149 identify parsing failure rather than one specific defect, a blanket search-and-replace can corrupt valid statements. Preserve the original dump and record every deliberate modification.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fixing packet-too-large and lost-connection errors

MySQL has separate max_allowed_packet limits on the client and server. The cited MySQL 26.7 Reference Manual gives example defaults of 16 MB for the mysql client and 64 MB for the server, and states a 1 GB maximum packet size. A statement larger than the effective limit can produce 1153, while the connection may surface as 2006 or 2013.

For a one-off client-side increase, use an option such as:

mysql --max_allowed_packet=32M -u user -p db1 < dump.sql

The server-side example is:

mysqld --max_allowed_packet=128M

Use values appropriate to the largest statement rather than setting an unnecessarily large limit. Change the server configuration through the method used by your deployment and restart or reload it when required. Then reconnect the client and retry the import. If the failure persists, inspect the server log and determine whether the server stopped, a timeout occurred, or a particular statement is malformed.

Validate the restore after the command finishes

A client returning to the prompt is not enough to prove that the application is usable. Run basic inventory checks and compare them with the source:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mysql -u user -p
SHOW DATABASES;
USE db1;
SHOW TABLES;
  • Confirm that every expected database and table is present.
  • Check views, triggers, stored routines, and other objects included in the source inventory.
  • Run targeted row-count checks for important tables and compare them with known source counts.
  • Verify the character sets and collations required by the application.
  • Perform an application smoke test using representative reads and writes.
  • Review the complete client output and server log for warnings that did not stop the command.

The exact checks depend on the application. A game backend, for example, may need a login test, a read of player records, and a controlled write to confirm that permissions and character handling are correct.

A safe repeatable restore procedure

  1. Keep the original dump unchanged and make a working copy only when a documented edit is necessary.
  2. Inspect the header for CREATE DATABASE and USE, and identify the source version if it is recorded.
  3. Confirm the target host, port, account, privileges, character set, and available disk space.
  4. Choose a clean database when the goal is a replacement restore; back up an existing target before changing it.
  5. Run the smallest correct command: mysql < dump.sql for a self-selecting dump, or mysql db1 < dump.sql for a single-database dump.
  6. If the import fails, fix the first error category identified by the client before addressing subsequent messages.
  7. Validate databases, tables, objects, row counts, character sets, and application behavior.
  8. Record the command, target version, configuration changes, and validation results so the restore can be repeated.

Choosing the right approach for your situation

Situation Preferred approach Main risk to check
Full server or multi-database SQL dump Run it without a database argument so the file’s own database statements execute. Account privileges to create and select every named database.
One schema exported without database statements Create the target if necessary, then run mysql db1 < dump.sql. Wrong database name or importing into a nonempty target.
Windows PowerShell workflow Use cmd.exe /c or Command Prompt for input redirection; create dumps with --result-file. PowerShell’s reserved < operator and UTF-16 output.
Large rows or inserts Measure the largest statement and adjust both client and server packet limits only as needed. 1153, 2006, or 2013 caused by mismatched limits or a server failure.
Cross-version restore Test in a disposable target and inspect syntax, SQL mode, reserved words, and character sets. 1064 or 1149 failures and altered interpretation of data.

Quick command reference

# Self-selecting dump
mysql -u user -p < dump.sql

# Single database already created
mysql -u user -p db1 < dump.sql

# Create then import
mysqladmin -u user -p create db1
mysql -u user -p db1 < dump.sql

# Explicit character set
mysql --default-character-set=utf8mb4 -u user -p db1 < dump.sql

# Larger client packet limit for one import
mysql --max_allowed_packet=32M -u user -p db1 < dump.sql

# PowerShell-compatible invocation
cmd.exe /c "mysql -u user -p db1 < dump.sql"

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.