Error
Error Code: 3503

MySQL Error 3503: Database Not Found

📦 MySQL
📋

Description

This error indicates that MySQL cannot locate a database with the specified name on the server. It commonly occurs when a connection attempt or SQL query references a database that does not exist, is misspelled, or has been deleted.
💬

Error Message

Database '%s' doesn't exist
🔍

Known Causes

4 known causes
⚠️
Incorrect Database Name
The database name provided in your SQL query or connection string contains a typo or misspelling.
⚠️
Database Not Created
The specified database has not yet been created on the MySQL server.
⚠️
Database Deleted
The database previously existed but has since been dropped or removed from the server.
⚠️
Case Sensitivity Mismatch
The database name casing in your query does not match the actual database name on a case-sensitive file system or MySQL configuration.
🛠️

Solutions

4 solutions available

1. Verify Database Name Spelling easy

Double-check that the database name in your query or connection string is spelled correctly.

1
Carefully review the SQL statement or application configuration where the database name is specified. Compare it character by character with the actual database name.
SELECT * FROM my_database.my_table; -- Ensure 'my_database' is spelled correctly
2
If you are connecting via an application, check the connection string or configuration file for typos in the database name parameter.
jdbc:mysql://localhost:3306/my_database

2. List Available Databases easy

Confirm the existence of the database by listing all databases on the server.

1
Connect to your MySQL server using a client (e.g., `mysql` command-line client, MySQL Workbench).
mysql -u your_username -p
2
Execute the `SHOW DATABASES;` command to list all databases.
SHOW DATABASES;
3
Examine the output to confirm if the database you are trying to access is present in the list. If it's not, you'll need to create it or use the correct name.
mysql> SHOW DATABASES;
+--------------------+

3. Create the Database easy

If the database legitimately does not exist, create it before attempting to use it.

1
Connect to your MySQL server with appropriate privileges.
mysql -u your_username -p
2
Execute the `CREATE DATABASE` statement, replacing `your_database_name` with the desired name.
CREATE DATABASE your_database_name;
3
Optionally, you can specify character set and collation if needed.
CREATE DATABASE your_database_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

4. Check MySQL User Permissions medium

Ensure the MySQL user you are connecting with has privileges to access the specified database.

1
Connect to your MySQL server as a user with sufficient privileges (e.g., `root`).
mysql -u root -p
2
Check the grants for the user you are using to connect.
SHOW GRANTS FOR 'your_username'@'your_host'; -- Replace 'your_username' and 'your_host'
3
If the user does not have privileges on the database, grant them. Replace 'your_username', 'your_host', and 'your_database_name' accordingly.
GRANT ALL PRIVILEGES ON your_database_name.* TO 'your_username'@'your_host' IDENTIFIED BY 'user_password';
FLUSH PRIVILEGES;
4
If the database was recently created, the user might not have been granted access. Ensure the user has at least `SELECT` privilege on the database.
GRANT SELECT ON your_database_name.* TO 'your_username'@'your_host';
🔗

Related Errors

5 related errors