Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How MySQL creates and selects databases

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how MySQL creates and selects the database, the content of the article is carefully selected and edited by the author, with a certain pertinence, and is of great significance to everyone's reference, the following is to understand with the author how MySQL creates and selects the database.

3.3.1 Creating and Selecting a Database3.3.1 create a selection database

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:

If the administrator creates a database for you and sets permissions for you, you can use it. Otherwise, you need to create your own database:

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.)

Under Unix, database names are case-sensitive (unlike the SQL keyword), so you must always refer to your database menagerie, not Menagerie,MENAGERIE or some other variant. The same is true of watch names. (under windows, it is case-insensitive, so you'd better use the same spelling as when creating tables or libraries. )

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".

Be careful

If you receive ERROR 1044 (42000): Access denied for user 'micah'@'localhost' to database' menagerie', this means that your user account does not have the necessary permissions to lock. Please discuss it with your administrator, or see Section 6.2, "MySQL access privileged Systems."

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

To create a database, you did not choose to use it, you must specifically specify that menagerie will be the database you use now, using the following statement:

Mysql > USE menagerieDatabase 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:

Your database needs to be created only once, but you must select it each time you start a mysql session. You can do this by issuing the USE statement shown in the example. Alternatively, you can select the database on the command line when calling mysql. Simply specify its name after any connection parameters you may need to provide. For example:

Shell > mysql-h host-u user-p menagerieEnter 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-pmypassword). 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.

important

Menagerie is not your password in the command just now. If you want to provide a password on the command line after the-p option, you must enter it immediately without inserting a space after the-p option (for example,-pmypassword is not-pmypassword). However, it is not recommended to put the password on the command line because doing so will cause it to be snooped by other users who log on to your computer.

Note

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

After reading the above about how MySQL creates and selects the database, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report