MySQL ERROR 1046 (3D000): No database selected
A query referenced tables without a database selected (no USE and no db in the connection).
Seen on:
MySQL
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 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026