Heim  >  Fragen und Antworten  >  Hauptteil

mysql数据库连接地址怎么确定?

素颜素颜2859 Tage vor4239

Antworte allen(5)Ich werde antworten

  • 想不出写啥

    想不出写啥2018-01-15 11:32:26

    mysql数据库连接地址怎么确定?-PHP中文网问答-mysql数据库连接地址怎么确定?-PHP中文网问答

    围观一下哦,学习一下。


    Antwort
    0
  • phpcn_u37517

    phpcn_u375172017-11-22 18:00:04

    用mysqli PDO都行

    Antwort
    0
  • 钟毅

    钟毅2017-10-04 17:32:23

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

    // some code

    ?>

    这个是第一种,适合所有版本。.


    <?php/* Connect to a MySQL server  连接数据库服务器 */$link = mysqli_connect(    'localhost',  /* The host to connect to 连接MySQL地址 */
       'jian',      /* The user to connect as 连接MySQL用户名 */
       '123456',  /* The password to use 连接MySQL密码 */
       'jian');    /* The default database to query 连接数据库名称*/if (!$link) {
       printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
       exit;
    }else
       echo '数据库连接上了!';/* Close the connection 关闭连接*/mysqli_close($link);?>

    这是第二种写法。php4.5后才可以。对象法。

    Antwort
    0
  • 数据分析师

    数据分析师2017-09-30 23:15:53

    mysql数据库连接地址怎么确定?-PHP中文网问答-mysql数据库连接地址怎么确定?-PHP中文网问答

    围观一下哦,学习一下。

    Antwort
    0
  • 迷茫

    迷茫2016-12-20 16:32:04

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

    Antwort
    1
  • StornierenAntwort