mysql数据库连接地址怎么确定?
素颜
素颜 2016-12-20 16:31:33
0
5
4291
素颜
素颜

越努力越幸运!!!

reply all(5)
想不出写啥

How to determine the mysql database connection address? -PHP Chinese website Q&A-How to determine the mysql database connection address? -PHP Chinese website Q&A

Let’s take a look and learn.


phpcn_u37517

Either use mysqli PDO

钟毅

<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect : ' . mysql_error());
}

// some code

?>

This is the first type and is suitable for all versions. .


##<?php/* Connect to a MySQL server Connect to the database server*/$link = mysqli_connect( 'localhost', /* The host to connect to Connect to MySQL Address*/

'jian', /* The user to connect as MySQL username*/
'123456', /* The password to use MySQL password*/
'jian'); / * The default database to query connection database name*/if (!$link) {
printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
exit;
}else
echo 'The database is connected! ';/* Close the connection Close the connection */mysqli_close($link);?>

This is the second way of writing. Only available after php4.5. object method.

数据分析师

How to determine the mysql database connection address? -PHP Chinese website Q&A-How to determine the mysql database connection address? -PHP Chinese website Q&A

Please watch and learn.

迷茫

jdbc:mysql://[数据库服务器IP地址]/[数据库名] 例如:局域网内一mysql服务器 IP地址为172.10.1.100,数据库名为test 链接地址为 jdbc:mysql://172.10.1.100/test 如果是本机,IP地址可以直接写为localhost

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template