MySQL ERROR 1046 (3D000): No database selected
A query referenced tables without a database selected (no USE and no db in the connection).
No database selected Meaning
Connections without a default database (DSN missing dbname) or imports without USE fail on the first unqualified table.
Common causes
- Connection string without database name
- SQL dump missing USE statement
- phpMyAdmin import with no database selected
⚡ Quick fix
- Add the database to the DSN/connection
- Run USE dbname first
- Select the database before importing in phpMyAdmin
Detailed fix by platform
MySQL
mysql -u app -p appdb < dump.sql
How to diagnose
- Connection — Database specified?
- Script — USE statement?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in MySQL
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 15 Oct 2026