mysql

作者: c667ec5a71d8 | 来源:发表于2019-05-11 23:11 被阅读0次

<?php

$dbhost = 'localhost:3306';  // mysql服务器主机地址

$dbuser = 'root';            // mysql用户名

$dbpass = '123456';          // mysql用户名密码

$conn = mysqli_connect($dbhost, $dbuser, $dbpass);

if(! $conn )

{

    die('连接失败: ' . mysqli_error($conn));

}

echo '连接成功<br />';

$sql = "CREATE TABLE runoob_tbl( ".

        "runoob_id INT NOT NULL AUTO_INCREMENT, ".

        "runoob_title VARCHAR(100) NOT NULL, ".

        "runoob_author VARCHAR(40) NOT NULL, ".

        "submission_date DATE, ".

        "PRIMARY KEY ( runoob_id ))ENGINE=InnoDB DEFAULT CHARSET=utf8; ";

mysqli_select_db( $conn, 'RUNOOB' );

$retval = mysqli_query( $conn, $sql );

if(! $retval )

{

    die('数据表创建失败: ' . mysqli_error($conn));

}

echo "数据表创建成功\n";

mysqli_close($conn);

?>

相关文章

网友评论

      本文标题:mysql

      本文链接:https://www.haomeiwen.com/subject/tixqaqtx.html