Select database for MySQL and database for mysql

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.