Select database for MySQL and database for mysql
After you connect to the MySQL database, there may be multiple databases that can be operated, so you need to select the database you want to operate.
Select MySQL database from the command prompt window
In the mysql> Prompt window, you can easily select a specific database. You can use SQL commands to select a specified database.
Instance
The following instance selects the database TUTORIALS:
[root@host]# mysql -u root -pEnter password:******mysql> use TUTORIALS;Database changedmysql>
After the preceding commands are executed, you have successfully selected the TUTORIALS database, which will be executed in the subsequent operations.
Note:All Database names, table names, and table fields are case sensitive. Therefore, you must enter the correct name when using SQL commands.
Use a PHP script to select a MySQL database
PHP provides the function mysql_select_db to select a database. If the function is successfully executed, TRUE is returned. Otherwise, FALSE is returned.
Syntax
bool mysql_select_db( db_name, connection );
Parameters |
Description |
Db_name |
Required. Specifies the database to be selected. |
Connection |
Optional. MySQL connection is required. If not specified, the previous connection is used. |
Instance
The following example shows how to use the mysql_select_db function to select a database:
Address: http://www.manongjc.com/mysql/mysql_select_database.html
Related reading:
Mysql join three table join query instances
Mysql distinct instance (filter redundant duplicate records)
Mysql count () and distinct instance and Efficiency Analysis
Mysql distinct usage and instance Introduction