您好,登錄后才能下訂單哦!
本文主要給大家介紹MySQL是如何創建并選擇數據庫的,文章內容都是筆者用心摘選和編輯的,具有一定的針對性,對大家的參考意義還是比較大的,下面跟筆者一起了解下MySQL是如何創建并選擇數據庫的吧。
If the administrator creates your database for you when setting up your permissions, you can begin using it. Otherwise, you need to create it yourself:
如果管理員為你創建數據庫并 為你設置了權限,你可以使用它。否則,您需要自己創建數據庫:
mysql> CREATE DATABASE menagerie;
Under Unix, database names are case sensitive (unlike SQL keywords), so you must always refer to your database as menagerie, not as Menagerie, MENAGERIE, or some other variant. This is also true for table names. (Under Windows, this restriction does not apply, although you must refer to databases and tables using the same lettercase throughout a given query. However, for a variety of reasons, the recommended best practice is always to use the same lettercase that was used when the database was created.)
在Unix下,數據庫名稱是區分大小寫的(不像SQL關鍵字),所以你必須總是指到你的數據庫 menagerie,而不是 Menagerie,MENAGERIE或一些其他變種。表名也是如此。(windows 下,大小寫不敏感,你最好使用與建表或者建庫時相同的拼寫。)
Note
If you get an error such as ERROR 1044 (42000): Access denied for user 'micah'@'localhost' to database 'menagerie' when attempting to create a database, this means that your user account does not have the necessary privileges to do so. Discuss this with the administrator or see Section 6.2, “The MySQL Access Privilege System”.
注意
如果您收到 ERROR 1044 (42000): Access denied for user 'micah'@'localhost' to database 'menagerie',這意味著您的用戶帳戶沒有鎖必須的權限。請與管理員討論,或參見第6.2節“MySQL訪問特權系統”。
Creating a database does not select it for use; you must do that explicitly. To make menagerie the current database, use this statement:
創建數據庫并沒有選擇使用它,你必須特別的指定,讓menagerie成為現在使用的數據庫,使用以下語句:
mysql> USE menagerie Database changed
Your database needs to be created only once, but you must select it for use each time you begin a mysql session. You can do this by issuing a USE statement as shown in the example. Alternatively, you can select the database on the command line when you invoke mysql. Just specify its name after any connection parameters that you might need to provide. For example:
您的數據庫只需要創建一次,但是每次開始mysql 會話時都必須選擇它。您可以通過發出USE如示例中所示的語句來執行此操作 。或者,您可以在調用mysql時在命令行中選擇數據庫。只需在您可能需要提供的任何連接參數之后指定其名稱。例如:
shell> mysql -h host -u user -p menagerie Enter password: ********
Important
menagerie in the command just shown is not your password. If you want to supply your password on the command line after the -p option, you must do so with no intervening space (for example, as -pmypassword, not as -p mypassword). However, putting your password on the command line is not recommended, because doing so exposes it to snooping by other users logged in on your machine.
重要
在剛剛的命令中 menagerie不是你的密碼。如果要在-p選項之后的命令行中提供密碼 ,你必須在-p選項后不插入空格馬上輸入(例如, -pmypassword 不是-p mypassword)。但是,不建議將密碼放在命令行上,因為這樣做會使其被登錄到您的計算機上的其他用戶窺探。
Note
You can see at any time which database is currently selected using SELECT DATABASE().
看完以上關于MySQL是如何創建并選擇數據庫的,很多讀者朋友肯定多少有一定的了解,如需獲取更多的行業知識信息 ,可以持續關注我們的行業資訊欄目的。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。