MySQL 参考手册 3.3.1 创建 选择数据库
2017-06-13 16:19
288 查看
3.3.1 Creating and Selecting a Database
3.3.1 创建 选择数据库
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
menageriethe current database, use this statement:创建数据库并没有选择使用它,你必须特别的指定,让menagerie成为现在使用的数据库,使用以下语句:
mysql> USE menagerie Database changedYour 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
USEstatement 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
menageriein the command just shown is not your password. If you want to supply your password on the command line after the
-poption, 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().注意
您可以随时查看当前使用哪个数据库。 SELECT DATABASE()
相关文章推荐
- 4、MySQL 8.0参考手册 连接到服务器并断开连接3.3.1创建和选择数据库
- MySQL 参考手册 3.3创建使用数据库
- 【sql入门】根据要求绘制E/R图,创建数据库(2)mySQL建表基本语法及主键外键选择
- mysql选择数据库创建数据库
- 10、MySQL 8.0参考手册 4.5.4 mysqldump - 数据库备份程序
- 6、MySQL 8.0参考手册 获取有关数据库和表格的信息
- MySQL中文参考手册--获得数据库和表的信
- 5、MySQL 8.0参考手册 3.3.4.1选择所有数据
- PHP - Manual手册 - Function Reference函数参考 - Database Extensions数据库扩展 - Vendor Specific Database Extensions特定提供商数据库扩展 - MySQL - MyS
- MySql语句常见操作-创建数据库,选择数据库,创建表,数据库中文乱码;
- MySQL - MySQL 5.1参考手册 - 9.语言结构 - 9.2. 数据库、表、索引、列和别名 - 9.2.2. 识别符大小写敏感性
- MySQL专题4之MySQL连接、MySQL数据类型、MySQL创建和删除以及选择数据库
- 4、MySQL 8.0参考手册 连接到服务器并断开连接3.3.2创建表格
- ubuntu mysql 创建并选择数据库
- MYSQL中文参考手册--创造并使用一个数据库
- MySql语句常见操作-创建数据库,选择数据库,创建表,数据库中文乱码;
- MySQL中文参考手册--MySQL教程(4)--创造并使用一个数据库
- MYSQL命令创建并选择数据库
- MYSQL创建、删除和选择数据库
- 5、MySQL 8.0参考手册 3.3.4.2选择特定的行