InletDownload

MySQL error 1049

ERROR 1049 (42000): Unknown database

The server has no database with that exact name. Check the spelling and letter case against SHOW DATABASES, make sure you’re on the server you think, and create it if it was never made.

ERROR 1049 (42000): Unknown database 'seo_shop'

Tested on MySQL 8.4.11 and MariaDB 11.4.13 · Updated 9 October 2026

What it means

In MySQL and MariaDB a database (also called a schema) is a named container for tables. Error 1049 means you named one the server doesn’t have: in the connection settings, in USE, or in a statement like CREATE TABLE shop.orders. The server checks the name exactly as you typed it.

You only see 1049 for databases you’d be allowed to use. If your account has no privileges on that name, the server answers with error 1044 instead, whether or not the database exists:

ERROR 1044 (42000): Access denied for user 'seo_mysql_app'@'%' to database 'seo_nope'

Common causes

  1. A typo in the database name, in a config file, environment variable or the path of a mysql:// URL.
  2. Letter case on Linux. On Linux servers, database names are case-sensitive by default (lower_case_table_names is 0): Shop and shop are different. On macOS and Windows they aren’t, so a name that worked locally can fail in production.
  3. It was never created. The official Docker images create MYSQL_DATABASE only on the very first start, when the data directory is empty; a volume from an earlier run keeps whatever it had.
  4. You’re on a different server than you think: another port, container or environment.
  5. It was dropped or renamed, or a restore hasn’t run yet.

How to fix it

List the databases you can see

SHOW DATABASES;

Find the name you meant, with its exact case. SHOW DATABASES lists only databases your account has some privilege on, so ask an administrator if you expect one that isn’t there. To confirm which server you’re on:

SELECT @@hostname, @@port, VERSION();

Use the exact name

Fix the name where it comes from: the database setting of your app, the path in mysql://<user>:<password>@<host>:3306/<database>, or the USE statement. See MySQL connection strings.

Create the database

If it should exist and doesn’t:

CREATE DATABASE shop CHARACTER SET utf8mb4;
GRANT ALL ON shop.* TO 'app'@'%';

With Docker, either create it like this or recreate the container with an empty volume so MYSQL_DATABASE (or MARIADB_DATABASE) takes effect.

Check the server’s case setting

SHOW VARIABLES LIKE 'lower_case_table_names';

0 means names are case-sensitive (Linux default), 1 means they’re stored in lower case and compared without case (Windows default), 2 means stored as written but compared without case (macOS default). MySQL 8 and MariaDB only accept it when the data directory is first initialised, so the fix is to use the right case, not to change the setting. Error 1146 covers the same rule for tables.

Reproduce it

On MySQL 8.4.11, as root:

mysql -h127.0.0.1 -uroot -p seo_shop -e 'select 1'
ERROR 1049 (42000): Unknown database 'seo_shop'

USE seo_shop and CREATE TABLE seo_shop.t (id int) fail the same way. With an existing database seo_mysql, a different case fails on this Linux server:

ERROR 1049 (42000): Unknown database 'Seo_MySQL'

MariaDB 11.4.13 gives the same message, number and SQLSTATE, with one difference: reading a table through a database that doesn’t exist reports the table rather than the database.

SELECT * FROM seo_shop.t;
-- MySQL 8.4
ERROR 1049 (42000): Unknown database 'seo_shop'
-- MariaDB 11.4
ERROR 1146 (42S02): Table 'seo_shop.t' doesn't exist

An account with no privileges on seo_nope got 1044 on both servers, as shown above; after GRANT ALL ON seo_mysql_nope.* TO 'seo_mysql_app'@'%', the same account connecting to the still-missing seo_mysql_nope got 1049.

In Inlet

Paste a mysql:// URL and Inlet fills in the connection form, so you can see the database name it read from the path before you connect. In the query editor, completion comes from the live schema, and query errors are shown with a hint.

Related

Sources