XWiki Cannot Connect to MySQL
Explanation
XWiki does not start. The browser shows an initialization failure, Could not initialize main XWiki instance, and the logs carry the reason:
Could not create a DBCP pool. There is an error in the Hibernate configuration file, please review it.Cause
XWiki could not open a connection to the MySQL server at all, so its connection pool was never created. Despite what the message says, the Hibernate configuration file is frequently correct: the pool reports itself as misconfigured as soon as its very first connection attempt fails, whatever the reason for that failure.
The usual reason is a MySQL server that is not listening where XWiki is looking. Either the server accepts no network connection at all, because skip-networking is enabled, or it is bound to a single interface through bind-address that does not include the address XWiki connects to.
Solution
- From the machine running XWiki, check whether the server answers at all. This is the same connection XWiki makes, without Hibernate in the way:
mysql -h <host> -u xwiki -pIf this fails too, the fault is on the MySQL side and no amount of editing XWiki's configuration will fix it.
- Open the MySQL server's configuration file and remove or comment out skip-networking, which stops the server from accepting any network connection.
- In the same file, set bind-address to an address the XWiki host can reach. A server left on 127.0.0.1 accepts connections from its own machine only, which is the usual surprise when XWiki runs on another host or in a container.
- Restart the MySQL server, then restart XWiki. The pool is created and the wiki is served.