(PHP 4, PHP 5)
mysql_create_db — 锟铰斤拷一锟斤拷 MySQL 锟斤拷锟捷匡拷
$database name
[, resource $link_identifier
] ) : boolmysql_create_db() 锟斤拷锟斤拷锟斤拷指锟斤拷锟斤拷锟斤拷锟接憋拷识锟斤拷锟斤拷锟斤拷锟侥凤拷锟斤拷锟斤拷锟较斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟捷库。
database_name
要锟斤拷锟斤拷锟斤拷锟斤拷锟捷匡拷锟斤拷锟斤拷
link_identifier
MySQL
锟斤拷锟接★拷锟界不指锟斤拷锟斤拷锟接憋拷识锟斤拷锟斤拷使锟斤拷锟斤拷 mysql_connect()
锟斤拷锟斤拷蚩锟斤拷锟斤拷印锟斤拷锟斤拷没锟斤拷锟揭碉拷锟斤拷锟斤拷锟接o拷锟结尝锟皆诧拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷
mysql_connect()
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷没锟斤拷锟揭碉拷锟斤拷锟接伙拷锟睫凤拷锟斤拷锟斤拷锟斤拷锟接o拷锟斤拷锟斤拷锟斤拷锟�
E_WARNING
锟斤拷锟斤拷拇锟斤拷锟�
锟缴癸拷时锟斤拷锟斤拷 TRUE
锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
锟斤拷
Example #1 锟斤拷锟� mysql_create_db() 锟斤拷锟斤拷锟斤拷
mysql_create_db() 锟斤拷锟斤拷锟窖凤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� mysql_query() 锟斤拷锟结交一锟斤拷 SQL 锟斤拷 CREATE DATABASE 锟斤拷锟斤拷锟斤拷锟斤拷妗�
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$sql = 'CREATE DATABASE my_db';
if (mysql_query($sql, $link)) {
echo "Database my_db created successfully\n";
} else {
echo 'Error creating database: ' . mysql_error() . "\n";
}
?>
锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�
Database my_db created successfully
Note:
锟斤拷锟斤拷展锟斤拷 PHP 5.5.0 锟斤拷锟窖凤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 PHP 7.0.0 锟斤拷始锟斤拷锟狡筹拷锟斤拷应使锟斤拷 MySQLi 锟斤拷 PDO_MySQL 锟斤拷展锟斤拷锟芥换之锟斤拷锟轿硷拷 MySQL锟斤拷选锟斤拷 API 指锟斤拷锟皆硷拷锟斤拷锟� FAQ 锟斤拷锟斤拷取锟斤拷锟斤拷锟斤拷息锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷校锟�
Note:
为锟斤拷锟斤拷锟铰硷拷锟捷o拷锟斤拷锟斤拷使锟斤拷锟斤拷锟斤拷锟窖凤拷锟斤拷锟侥憋拷锟斤拷锟斤拷 mysql_createdb()
Note:
锟斤拷锟� MySQL 锟斤拷展锟角伙拷锟斤拷 MySQL 4.x 锟酵伙拷锟剿匡拷锟斤拷锟侥伙拷锟津本猴拷锟斤拷锟斤拷锟斤拷锟矫★拷