What is the fix for MySQL server refuse to connect issue?

Posted November 19, 2021 109 views
MySQLPHPPHP FrameworksDatabasesLaravel

I’ve deployed a Laravel application on a CentOS droplet with MySQL. The issue is after I use Laravel tinker or use PHPMyAdmin, I get “Connection refused”. I have to restart MySQL server from SSH.

Any idea what’s the issue here? Thanks in advance.

1 comment
  • FYI, I did a tail on mysql logs when this happen.

    2021-11-21T07:06:58.671269Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.26) starting as process 33039
    2021-11-21T07:06:58.696453Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    2021-11-21T07:06:59.605756Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    2021-11-21T07:07:12.156123Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
    2021-11-21T07:07:12.163376Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
    2021-11-21T07:07:12.382972Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
    2021-11-21T07:07:12.383191Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
    2021-11-21T07:07:12.396101Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
    2021-11-21T07:07:12.396435Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
    2021-11-21T07:07:12.443710Z 0 [System] [MY-010931] [Server] /usr/libexec/mysqld: ready for connections. Version: '8.0.26'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution.
    2021-11-21T07:07:12.443811Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/lib/mysql/mysqlx.sock

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there,

Does the MySQL service run fine after you restart it?

If so I could suggest a couple of things:

  • Follow the steps here on how to tweak MySQL/MariaDB Configuration for Increased Performance and Stability:

  • Check your system logs and MySQL logs to see what is causing MySQL to crash. You can find the logs at the /var/log directory.

As a side note, with all of the recent CentOS changes, I now personally use Ubuntu to host my Laravel applications. Along with this automation script that sets up the whole server for me:

Let me know how it goes.