SQLSTATE[HY000] [2002] using database cluster with Laravel

My setup:

  • Laravel 8.83.20
  • PHP 7.4.30
  • MySQL 8.0.26
  • IP added under access control

And in config/database.php under mysql:

            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
                PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
            ]) : [],

And then for environment variables:

DB_CONNECTION=mysql
DB_HOST=(hidden)
DB_PORT=3306
DB_DATABASE=(hidden)
DB_USERNAME=linroot
DB_PASSWORD=(hidden)
MYSQL_ATTR_SSL_CA=/var/lib/mysql/cert.pem

I ran config:clear but still getting SQLSTATE[HY000] [2002]. I should mention that I am able to connect from said server via the mysql command, whether I use the ssl-ca option or not.

Any ideas? Much appreciated!

4 Replies

@ryanduval There could be a few reasons why you're having trouble accessing your cluster via Laravel. There are two Community Questions post that may help you with your troubleshooting. I've linked them down below.

You may also come across some Laravel specific support on their community forum.

The Laravel Forum

Hope this helps you out some!

The first post suggests the port is wrong, but I'm using the default 3306, which is also what the cluster uses. I would love to look at the logs to see what is happening, but Linode controls that.

The second post doesn't seem related as we're not using a socket connection.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct