1046 🐬 MySQL

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

  1. Add the database to the DSN/connection
  2. Run USE dbname first
  3. Select the database before importing in phpMyAdmin

Detailed fix by platform

MySQL

  1. mysql -u app -p appdb < dump.sql

How to diagnose

  1. Connection — Database specified?
  2. 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.