"Unknown database" MySQL Error
Last modified by Eleni Cojocariu on 2026/09/10 20:35
Content
Explanation
XWiki starts, fails to open its database, and the logs carry a JDBC exception whose message is:
Unknown database 'xwiki'Cause
XWiki reached the MySQL server, had the host, port, user or password been wrong, the failure would have come before this one, but that server holds no schema under the name the connection URL asks for. xwiki is the name XWiki looks for by default, so the mismatch takes one of two shapes: a database created under a different name while the configuration still asks for xwiki, or a configuration naming a database that was never created, such as jdbc:mysql://localhost/abcd##.
Solution
- Connect to the MySQL server and list what it actually holds:
SHOW DATABASES; - Compare that list with the database named at the end of hibernate.connection.url in the WEB-INF/hibernate.cfg.xml file. Either the database or the configuration has to change.
- If the database is simply missing, create it with the character set and collation XWiki expects, the create-database step of Configure MySQL gives the statement.
- If the database exists under another name, point XWiki at that name instead: put it at the end of hibernate.connection.url, and, when the main wiki's database is not called xwiki, also set the xwiki.db property in the WEB-INF/xwiki.cfg file, as the create-database step of Configure MySQL describes.
- Restart XWiki. It connects to the database the configuration names and creates its tables there.