Connection refused error when connecting to MySQL database in Jira server
Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.
User unable to connect to MySQL while trying to configure JIRA for the first time. After creating the database and going through the setup process, user is prompted *Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.* error.
Ubuntu 14.04 Server
JDBC Driver : mysql-connector-java-5.1.38-bin.jar
Ensure the database created is detected. Use show databases; query in MySQL to see all the database.
- Run netstat -tln command in terminal to see whether MySQL is listening to port 3306 in localhost
- Login to MySQL in terminal and run SHOW GRANTS FOR 'jira'@'localhost'; to check whether the JIRA user is permitted to access the database from localhost.
Previously if the MySQL is setup to have remote access, it might be configured to access the LAN IP rather than localhost (127.0.0.1:3306) IP. If any user setup MySQL in localhost, JIRA will be unable to connect to MySQL because MySQL is not connected to localhost.
If MySQL is listening to LAN IP, change it back so it listen to the localhost.
- Open /etc/mysql/my.cnf in a text editor
- Change the bind-address = 192.X.X.X to bind-address = 127.0.0.1 and save
Restart MySQL service
- Use netstat -tln to verify that MySQL is listening in localhost 127.0.0.1:3306 port.