[TriLUG] Stuck -- PHP MySQL ( 22nd )

Michael Kimsal via TriLUG trilug at trilug.org
Mon Aug 22 17:09:45 EDT 2022


First thought - change the php pdo connection string from localhost to
127.0.0.1.


On Mon, Aug 22, 2022 at 3:45 PM Brian McCullough via TriLUG <
trilug at trilug.org> wrote:

>
> Well, I seem to have another one.
>
>
> I am trying to write a very simple PHP command line program, using PDO,
> to read a database on my machine.  Easy, right?   No.
>
> I have a local 5.6.10 database in my machine, living in
> /usr/local/mysql, which wants to put its socket file in /tmp.
>
> Running mysql at the command line, everything works.  Running my PHP
> program, it reports, using the same credentials, "localhost" and port
> number, "Connection refused."
>
> OK, so maybe PHP and MySQL are looking at different places for the
> socket.  After some research, I explicitly specified
> "/var/run/mysqld/mysqld.sock" in my.cnf ( and
> /etc/mysql/mysqld.conf.d/mysqld.conf ), and "mysql" works correctly.
>
> The PHP program still refuses to connect.  I went in to php.ini and
> added the socket address to both the mysqli and pdo_mysql sections.  No
> change in result.
>
> I also happen to have a Docker container running a different MySQL
> database ( under Laravel Sail ), using a different port number, so that
> I don't conflict with the "local" one.  Using "mysql -h docker-address
> -P 3360 -u sail -p" didn't work, because ( among other things ) "mysql"
> is, of course, the local ( 5.6.10 version ) while the Docker version is
> 8.0.30.
>
> The PHP program fails to connect there, but I don't have a good working
> test, although "telnet docker-address 3360" and "telnet localhost 3306"
> both give reasonable results.
>
>
> That should cover all of my digging and experiments.  Does anybody have
> any bright ideas?
>
>
> Thank you,
> Brian
>
> --
> This message was sent to: mgkimsal at gmail.com <mgkimsal at gmail.com>
> To unsubscribe, send a blank message to trilug-leave at trilug.org from that
> address.
> TriLUG mailing list : https://www.trilug.org/mailman/listinfo/trilug
> Unsubscribe or edit options on the web  :
> https://www.trilug.org/mailman/options/trilug/mgkimsal%40gmail.com
> Welcome to TriLUG: https://trilug.org/welcome



-- 

Michael Kimsal
https://michaelkimsal.com
919.271.1162


More information about the TriLUG mailing list