Cannot connect to mysql using bitnami battery stack via php

Well, that will be a long question.

I try to get something and run my account at the university. We have a public_html folder that we can use as a web space to host everything we want there.

I installed the Bitnami battery stack in the public_html folder (maybe not a good idea from a security point of view, but I'm going to test this application for a couple of days and pull it out so that I really don't have that long, I can run it quickly and quickly), and the site I want to host works fine and is accessible via (http: // (uni address) / (my account name) / public_html / lamp / apache2 / htdocs / (etc.). However, some parts of the code, which connects to the database give me the following warning:

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I connect to the database using the following code:

mysql_connect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass);

Where dbhost is "localhost".

Since it refers to /var/run/mysqld/mysqld.sock - this obviously means that it is trying to connect to the wrong thing, since mysql in the lamp stack that I installed has the following in my.cnf:

[mysqladmin]
user=root

[mysqld]
basedir=(my account folder)/public_html/lamp/mysql
datadir=(my account folder)/public_html/lamp/mysql/data
port=3306
socket=(my account folder)/public_html/lamp/mysql/tmp/mysql.sock
tmpdir=(my account folder)/public_html/lamp/mysql/tmp

[mysqld_safe]
mysqld=mysqld.bin

[client]
port=3306
socket=(my account folder)/public_html/lamp/mysql/tmp/mysql.sock

[manager]
port=3306
socket=(my account folder)/public_html/lamp/mysql/tmp/mysql.sock
pid-file=(my account folder)/public_html/lamp/mysql/tmp/manager.pid
default-mysqld-path=(my account folder)/public_html/lamp/mysql/bin/mysqld.bin

, : - , ? , var/run/mysqld/mysqld.sock , , , ( , , ).

. .

!

+3
1

, , my.cnf, mysql_connect ( № 3) localhost, $CFG- > dbhost ​​

$CFG->dbhost = ':(my account folder)/public_html/lamp/mysql/tmp/mysql.sock';
$link = mysql_connect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass);

, !

, mysql "( )/public_html/lamp/mysql/tmp/mysql.sock"


Edit:

, socks mysql , , -, .

, mysql , .

mysql --socket=<my account folder>/public_html/lamp/mysql/tmp/mysql.sock -u <username> -p

2:

, , .

.

/home/<username>/public_html/lamp/mysql/tmp/mysql.sock
+1

Source: https://habr.com/ru/post/1722242/


All Articles