溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

MySQL是如何創(chuàng)建并選擇數(shù)據(jù)庫的

發(fā)布時(shí)間:2020-05-08 11:51:47 來源:億速云 閱讀:294 作者:三月 欄目:數(shù)據(jù)庫

本文主要給大家介紹MySQL是如何創(chuàng)建并選擇數(shù)據(jù)庫的,文章內(nèi)容都是筆者用心摘選和編輯的,具有一定的針對性,對大家的參考意義還是比較大的,下面跟筆者一起了解下MySQL是如何創(chuàng)建并選擇數(shù)據(jù)庫的吧。

3.3.1 Creating and Selecting a Database

3.3.1 創(chuàng)建 選擇數(shù)據(jù)庫

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:

如果管理員為你創(chuàng)建數(shù)據(jù)庫并 為你設(shè)置了權(quán)限,你可以使用它。否則,您需要自己創(chuàng)建數(shù)據(jù)庫:

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下,數(shù)據(jù)庫名稱是區(qū)分大小寫的(不像SQL關(guān)鍵字),所以你必須總是指到你的數(shù)據(jù)庫 menagerie,而不是 Menagerie,MENAGERIE或一些其他變種。表名也是如此。(windows 下,大小寫不敏感,你最好使用與建表或者建庫時(shí)相同的拼寫。)

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',這意味著您的用戶帳戶沒有鎖必須的權(quán)限。請與管理員討論,或參見第6.2節(jié)“MySQL訪問特權(quán)系統(tǒng)”。

Creating a database does not select it for use; you must do that explicitly. To make menagerie the current database, use this statement:

創(chuàng)建數(shù)據(jù)庫并沒有選擇使用它,你必須特別的指定,讓menagerie成為現(xiàn)在使用的數(shù)據(jù)庫,使用以下語句:

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:

您的數(shù)據(jù)庫只需要創(chuàng)建一次,但是每次開始mysql 會話時(shí)都必須選擇它。您可以通過發(fā)出USE如示例中所示的語句來執(zhí)行此操作 ?;蛘?,您可以在調(diào)用mysql時(shí)在命令行中選擇數(shù)據(jù)庫。只需在您可能需要提供的任何連接參數(shù)之后指定其名稱。例如:


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選項(xiàng)之后的命令行中提供密碼 ,你必須在-p選項(xiàng)后不插入空格馬上輸入(例如, -pmypassword 不是-p mypassword)。但是,不建議將密碼放在命令行上,因?yàn)檫@樣做會使其被登錄到您的計(jì)算機(jī)上的其他用戶窺探。

Note

You can see at any time which database is currently selected using SELECT DATABASE().

看完以上關(guān)于MySQL是如何創(chuàng)建并選擇數(shù)據(jù)庫的,很多讀者朋友肯定多少有一定的了解,如需獲取更多的行業(yè)知識信息 ,可以持續(xù)關(guān)注我們的行業(yè)資訊欄目的。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI