After you connect to the MySQL database, there may be multiple databases can operate, so you need to select the database you want to operate.
Select the MySQL database from the command prompt window
In the mysql> prompt window can be very simple to select a specific database. You can use SQL commands to select the specified database.
Examples
The following examples selected database CODERCTO:
[root@host]# mysql -u root -p
Enter password:******
mysql> use CODERCTO;
Database changed
mysql>
After executing the above command, you have successfully chosen CODERCTO database, the database will be executed in CODERCTO in subsequent operations.
Note: All database names, table names, table fields are case sensitive. So you need to enter the correct name when using SQL commands.
MySQL database using PHP script selection
PHP provides functions mysqli_select_db to select a database. After performing the function returns TRUE if successful, otherwise FALSE.
grammar
mysqli_select_db(connection,dbname);
Parameter Description
connection required. MySQL provisions connection to use.
dbname necessary, provisions default database to use.
Examples
The following example shows how to use mysqli_select_db function to select a database:
Select Database
(Editor: Leilin Peng Source: network intrusion deleted)