search

Home  >  Q&A  >  body text

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

素颜素颜2972 days ago4351

reply all(5)I'll reply

  • 想不出写啥

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

    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.


    reply
    0
  • phpcn_u37517

    phpcn_u375172017-11-22 18:00:04

    Either use mysqli PDO

    reply
    0
  • 钟毅

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

    <?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.

    reply
    0
  • 数据分析师

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

    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.

    reply
    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

    reply
    1
  • Cancelreply