Home > database >  How baidu cloud database connections, has been an error.
How baidu cloud database connections, has been an error.

Time:10-06

Database link failure, error message: Can 't connect to local MySQL server through socket'/var/run/mysqld/mysqld. The sock '(2),


User name, password, address, are all right, here is my code, a great god taught,
<? PHP
The header (" content-type: text/HTML; Charset=utf-8 ");
//link to the mysql database, set up the server address, user name, address,
//constant parameters,
$dbname='ZUEUmNusqMJVLEhyYCCP';

/* from the environment variable parameter database connection need */
$host=getenv (" sqld-gz.bcehost.com ");
$port=getenv (' 3306 ');
$user=getenv (' 99 e349495cff4a95989bb74f511a8915 ');
$PWD=getenv (' 547 e172845af488ba82d76c3dfafcb49 ');
$conn=@ mysql_connect ($host, port, $user and $PWD) or die (' database link failure, error message: 'the. Mysql_error ());

//the second step is to select the database to link, and set the character set,
The mysql_select_db ($dbname, $conn) or die (' database error!!!!! Error message: ". Mysql_error ());
Mysql_query (' SET NAMES UTF8) or die (' character SET wrong!!!!! Error message: ". Mysql_error ());
//the third department, choose a list of the database, then put this table have been extracted from the database,
$query='SELECT * FROM art';
$result=mysql_query ($query) or die (' SQL error!!!!! Error message: ". Mysql_error ());
//$result is recordset
//the fourth step, can display the data in a recordset
Print_r (mysql_fetch_array ($result, MYSQL_ASSOC));

CodePudding user response:

The client can connect?

CodePudding user response:

Mysql service open, he this is a used phpMyadmin operation management

CodePudding user response:

refer to the second floor JasonBoss163 response:
mysql service open, he is a with the phpMyadmin operation management
phpMyadmin can operate database link?

CodePudding user response:

O o can operate

CodePudding user response:

Baidu cloud server, database on the server, the connection, thank you, there has been no reply,
  • Related