Error
Error Code:
1102
MariaDB Error 1102: Invalid Database Name Specified
Description
Error 1102 indicates that MariaDB cannot find or recognize the database name provided in a SQL statement or connection attempt. This typically occurs when the specified database either does not exist on the server or is misspelled, preventing access or manipulation of data within it.
Error Message
Incorrect database name '%s'
Known Causes
4 known causesTypo or Misspelling
The database name specified in the SQL query, command-line argument, or application connection string contains a typographical error.
Database Does Not Exist
The database name provided refers to a database that has not yet been created or was previously dropped from the MariaDB server.
Case Sensitivity Mismatch
On operating systems where MariaDB's database names are case-sensitive (e.g., Linux), the specified name does not exactly match the case of the actual database name on the server.
Invalid Naming Convention
The provided database name violates MariaDB's naming rules, such as containing forbidden characters or starting with an invalid character.
Solutions
4 solutions available1. Verify Database Name in Connection String or Query easy
Double-check the database name used in your application's connection string or SQL queries.
1
Locate the part of your application code or script that establishes the database connection or executes a query that specifies a database. This is often found in configuration files, connection strings, or within the SQL statements themselves.
2
Carefully examine the database name provided. Ensure it exactly matches an existing database name on your MariaDB server, paying close attention to spelling, capitalization (if your operating system/MariaDB configuration is case-sensitive for database names), and any leading/trailing spaces.
3
If you are connecting via a command-line tool or a script, ensure the database name is correctly passed as an argument or within the command.
mysql -u your_user -p your_database_name
4
If you are using a programming language's database connector, review the connection string parameters or the `USE` statement in your SQL.
connection_string = "Server=your_host;Database=your_database_name;Uid=your_user;Pwd=your_password;"
2. List Available Databases and Correct Typo easy
Query MariaDB to see existing databases and identify the correct name to use.
1
Connect to your MariaDB server using a client tool (e.g., `mysql` command-line client, DBeaver, MySQL Workbench).
mysql -u your_user -p
2
Once connected, execute the `SHOW DATABASES;` command to list all available databases.
SHOW DATABASES;
3
Compare the output of `SHOW DATABASES;` with the database name you are trying to use. Identify any typos, case differences, or missing characters.
4
Correct the database name in your application's configuration, connection string, or SQL query to match one of the existing database names.
3. Create the Database if it Doesn't Exist easy
If the intended database is genuinely missing, create it.
1
Connect to your MariaDB server using a client tool.
mysql -u your_user -p
2
Execute the `CREATE DATABASE` statement with the correct database name.
CREATE DATABASE your_database_name;
3
Verify that the database was created successfully by running `SHOW DATABASES;`.
SHOW DATABASES;
4
Ensure your application or script is now configured to use this newly created database.
4. Check MariaDB User Privileges for Database Access medium
Confirm that the MariaDB user has the necessary permissions to access the specified database.
1
Connect to your MariaDB server as a user with sufficient privileges (e.g., `root` or another administrative user).
mysql -u root -p
2
View the privileges granted to the user who is encountering the error for the specific database. Replace `your_user` and `your_database_name` accordingly.
SHOW GRANTS FOR 'your_user'@'localhost' USING 'your_database_name';
3
If the user lacks necessary privileges (e.g., `SELECT`, `INSERT`, `UPDATE`, `DELETE` for tables within the database, or `USAGE` for the database itself), grant them. The `USAGE` privilege is often required to even 'see' or connect to a database.
GRANT USAGE ON `your_database_name`.* TO 'your_user'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON `your_database_name`.* TO 'your_user'@'localhost';
4
Flush privileges to ensure the changes take effect immediately.
FLUSH PRIVILEGES;