Get the App
SLTechnology News&Howtos  ›  Database  › 

How to select MySQL database

Shulou Source: shulou.com Published: 2022-05-31 16:08:58 09月22日 Update

This article mainly introduces how to choose the MySQL database, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

MySQL Select Database

After you connect to the MySQL database, there may be multiple operational databases, so you need to select the database you want to operate on.

Select the MySQL database from the command prompt window

You can easily select a specific database in the mysql > prompt window. You can use the SQL command to select the specified database.

Example

The following example selects the database chenweiliang:

[root@host] # mysql-u root-pEnter password:*mysql > use chenweiliang;Database changedmysql >

After executing the above command, you have successfully selected the chenweiliang database, which will be executed in the chenweiliang database in subsequent operations.

Note: all database names, table names, and table fields are case sensitive. So you need to enter the correct name when using the SQL command.

Use PHP script to select MySQL database

PHP provides the function mysqli_select_db to select a database. The function returns TRUE after successful execution, otherwise it returns FALSE.

Syntax mysqli_select_db (connection,dbname); parameter description connection is required. Specifies the MySQL connection to be used. Dbname is required to specify the default database to use. Example

The following example shows how to use the mysqli_select_db function to select a database:

Thank you for reading this article carefully. I hope the article "how to choose MySQL Database" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Data database selection command instance article function success prompt value interest parameter simultaneously name multiple size field more friends knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Huawei Redmi Linux macOS