<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sql on shocksolution.com</title><link>https://shocksolution.com/tags/sql/</link><description>Recent content in Sql on shocksolution.com</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 14 May 2018 18:58:47 +0000</lastBuildDate><atom:link href="https://shocksolution.com/tags/sql/index.xml" rel="self" type="application/rss+xml"/><item><title>Configuring Laravel/Lumen applications to connect to SQL database sockets</title><link>https://shocksolution.com/posts/configuring-laravel-lumen-applications-to-connect-to-sql-database-sockets/</link><pubDate>Mon, 14 May 2018 18:58:47 +0000</pubDate><guid>https://shocksolution.com/posts/configuring-laravel-lumen-applications-to-connect-to-sql-database-sockets/</guid><description>&lt;p&gt;The Laravel/Lumen framework documentation does not explain how to connect an application to a database using UNIX sockets instead of a TCP-based network connection. I recently had to configure the &lt;a href="https://polrproject.org/"&gt;Polr URL shortener&lt;/a&gt; (built on the &lt;a href="https://lumen.laravel.com/"&gt;Lumen microframework&lt;/a&gt; by &lt;a href="https://laravel.com/"&gt;Laravel&lt;/a&gt;) to connect to Google Cloud SQL with a UNIX socket. Since all of Polr&amp;rsquo;s configuration takes place in the &lt;strong&gt;.env&lt;/strong&gt; file, and there is no environment variable that&amp;rsquo;s specific to database sockets, this took some research. I finally found the answer in an &lt;a href="https://stackoverflow.com/questions/29305502/php-artisan-migrate-with-mamp-and-unix-socket/39509268#39509268"&gt;obscure StackOverflow response&lt;/a&gt;. Previous TCP connection: [code] DB_HOST=some-server-name DB_PORT=3306 [/code] Socket-based SQL connection: [code] DB_HOST=localhost;unix_socket=/cloudsql/cloud-project-name:us-east1:sql-instance-name [/code] This approach will work with any UNIX socket; you just need to give it the absolute path to the socket.&lt;/p&gt;</description></item></channel></rss>