0

Bearing in mind I'm trying to run in a docker environment with php 5.4 due to Kohana PHP MVC being a framework which hasn't been updated and is no longer going to be supported, get following error

mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(2) ["file":protected]=> string(64) "/var/www/html/modules/database/classes/kohana/database/mysql.php

my docker command is

sudo docker run -d -p 8080:80 -p 3307:3306 -p 22:22  -v   "/home/me/public_html/project-folder:/var/www/html" ushios/lamp-ubuntu

Am I missing something to make it work with the database, thanks

GAV
  • 1,205
  • 2
  • 18
  • 38
  • Why are you doing `-p 3307:3306` ? – apokryfos Feb 10 '17 at 15:45
  • see my previous problem http://stackoverflow.com/questions/42162285/docker-using-mysql – GAV Feb 10 '17 at 15:48
  • **Warning**: You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) which has been **removed** entirely from the latest version of PHP. You should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). – Quentin Feb 10 '17 at 16:39

2 Answers2

1

It doesn't look like your PHP settings are using the tcp connector.

Can't connect to local MySQL server through socket

It seems to be using the '/var/run/mysqld/mysqld.sock'. The mysql_connect call defaults to using various PHP settings in absence of parameters.

Check your setting in PHP and the mysql_connect() call itself.

My guess is that you either need to:

  • Change the default settings
  • Add parameters to the mysql_connect call.

As an aside, mysql_ is depreciated, you should use the mysqli_ set of calls if possible.

SH-
  • 1,642
  • 10
  • 13
1

Docker file: - docker-php-ext-install mysqli - docker-php-ext-enable mysqli

On code: Use mysqli_connect instead mysql_connect