From the command prompt, select the MySQL database:
It is very simple to select a specific database mysql> prompt. Select a specific database, and you can use the SQL command.
Example:
The following is an example of selecting a database called tutorials:
The code is as follows |
Copy Code |
[root@host]# mysql-u Root-p Enter password:****** mysql> use tutorials; Database changed Mysql> |
Now you have selected the Tutorial database tutorial database and all subsequent operations will be done.
Note: All database names, table names, and field names in the table are case-sensitive. So you will have to use the Prpoer name and give any SQL commands.
use PHP script to select MySQL database :
PHP provides a function mysql_select_db select a database. Returns true successfully, otherwise returns false.
Here is an example showing how to select a database.
The code is as follows |
Copy Code |
<title>selecting MySQL database-by www.111cn.net</title> <body> <?php $dbhost = ' localhost:3036 '; $dbuser = ' guest '; $dbpass = ' guest123 '; $conn = mysql_connect ($dbhost, $dbuser, $dbpass); if (! $conn) { Die (' Could not connect: '. Mysql_error ()); } Echo ' Connected successfully '; mysql_select_db (' tutorials '); Mysql_close ($conn); ?> </body>
|