閱讀569 返回首頁    go 阿裏雲 go 技術社區[雲棲]


mysql創建數據庫命令與語句

創建數據庫
create database 語句用於在 mysql 中創建數據庫。

語法
create database database_name為了讓 php教程執行上麵的語句,我們必須使用 mysql_query() 函數。此函數用於向 mysql 連接發送查詢或命令。

方法一,利用cmd形式創建數據庫

c:program filesphps教程tudymysqlbin>mysql -u root -p
enter password: ****

//輸入數據庫用戶名與密碼

welcome to the mysql monitor.  commands end with ; or g.
your mysql connection id is 235
server version: 5.0.51b-community-nt mysql community edition (gpl)

type ‘help;’ or ‘h’ for help. type ‘c’ to clear the buffer.

mysql> create database exdb; //創建數據庫exdb成功
query ok, 1 row affected (0.00 sec)

mysql>

方法二,在php程序創建數據庫

<?
$cn = mysql_connect(’localhost’,'root’,'root’) or die(’mysql connect fail’);
if (mysql_query(”create database exdb”,$cn))
  {
  echo “database created”;
  }
else
  {
  echo “error creating database: ” . mysql_error();
  }
?>

文章來源於站長天空

最後更新:2017-01-04 22:34:51

  上一篇:go Discuz!與UCHome共存的偽靜態設置
  下一篇:go Windows2003服務器重啟IIS解決故障