Macports with php development server not connecting to mariadb. Mysql server has gone away
Get the solution ↓↓↓I am trying to connect to a local MariaDB instance on my Mac with php8 that I installed with MacPortssudo port install mariadb-server
(php also installed withsudo port install php80
and alsosudo port install php80-mysql
for the extension), and I am not able to make a connection.
The error I get is a little unintuitive:
~> php -a
Interactive shell
php > $conn = new PDO('mysql:host=127.0.0.1;port=5900;dbname=mysimplechat', 'root', 'PASSWORD');
Warning: Uncaught PDOException: Packets out of order. Expected 0 received 32. Packet size=4343378 in php shell code:1
Stack trace:
#0 php shell code(1): PDO->__construct('mysql:host=127....', 'root', 'PASSWORD')
#1 {main}
Next PDOException: SQLSTATE[HY000] [2006] MySQL server has gone away in php shell code:1
Stack trace:
#0 php shell code(1): PDO->__construct('mysql:host=127....', 'root', 'PASSWORD')
#1 {main}
thrown in php shell code on line 1
I have tried, to no avail, to change /opt/local/etc/mariadb/my.cnf from:
# Use default MacPorts settings
!include /opt/local/etc/mariadb/macports-default.cnf
to:
[mysqld]
max_allowed_packet=64M
and still get this error.
Any help would be appreciated.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: illuminate\http\exceptions\posttoolargeexception
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.