昨天南昌網(wǎng)絡公司小編為大家介紹了關于Linux中mysql命令的用法,那么今天就來為大家介紹一下linux中MySQL數(shù)據(jù)庫的創(chuàng)建方法。
MySQL服務器將數(shù)據(jù)組織成數(shù)據(jù)庫,數(shù)據(jù)庫通常保存著單個應用程序的數(shù)據(jù),與用這個數(shù)據(jù)庫服務器的其他應用互不相關。為每個shell腳本應用創(chuàng)建一個單獨的數(shù)據(jù)庫有助于消除混淆,避免數(shù)據(jù)混用。
創(chuàng)建一個新的數(shù)據(jù)庫要用如下SQL語句。
CREATE DATABASE name;
非常簡單,當然了,你必須擁有在MySQL服務器上創(chuàng)建新數(shù)據(jù)庫的權限。簡單的辦法是作為root用戶登錄MySQL服務器。
$ mysql -u root –p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 42
Server version: 5.5.38-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> CREATE DATABASE mytest;
Query OK, 1 row affected (0.02 sec)
mysql>
可以使用SHOW命令來查看新數(shù)據(jù)庫是否創(chuàng)建成功。
好了,它已經(jīng)成功創(chuàng)建了。
以上就是南昌網(wǎng)絡公司小編為大家介紹的關于linux中MySQL數(shù)據(jù)庫的創(chuàng)建方法,是不是很簡單呢?雖然簡單,但是大家在編寫代碼時也要仔細一點,避免出錯!了解更多關于數(shù)據(jù)庫方面的知識,歡迎訪問公司官網(wǎng)。此外,百恒網(wǎng)絡專業(yè)為您提供網(wǎng)站建設、微信開發(fā)、APP開發(fā)、網(wǎng)站推廣等服務,如有需要,百恒隨時為您效勞!