# MySQL ERROR 1046 (3D000): No database selected

**Code:** `1046` · **Category:** MySQL · **Seen on:** MySQL

A query referenced tables without a database selected (no USE and no db in the connection).

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/mysql/1046-no-database-selected)
