mysql API socket connection

[problem]

Sometimes you need to connect to mysql server with a UNIX socket, rather than a Port.

Generally this is when running multiple versions, on a box when you do not want to
or cannot connect to multiple ports.

[/problem]

[solution]

If you want to connect to the mysql server from the command line, you can use -S.

Or within Perl – append mysql_socket to the dsn

[/solution]

[example]


mysql -uUSER -pPASSWORD -S /tmp/mysql.sock


dbi:mysql:database=database_name;mysql_socket=/tmp/mysql.sock

Where your socket is /tmp/mysql.sock

[/example]

[reference]

[tags]MySQL, Socket, UNIX, Perl, Perl Coding School[/tags]

[/reference]

If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *