DBA: Multiple ways to select MySQL database

Source: Internet
Author: User
Tags dba

First, the command line mode
MySQL [(none)]> show databases;        #未选择数据库前,显示(none)表示在数据库跟路径下+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || sys                || viewtest           |+--------------------+5 rows in set (0.02 sec)MySQL [(none)]> use viewtest;   Database changedMySQL [viewtest]>                             #选择数据库后,就会显示你当前的数据库名称
Second, PHP way to select MySQL Database

Grammar:
mysqli_select_db (Connection,dbname)

Instance operations:

[[email protected] web]# cat query.php<?$dbhost = ‘localhost:3306‘;$dbuser = ‘root‘;$dbpass = ‘000000‘;$conn = mysqli_connect($dbhost,$dbuser,$dbpass);if ( ! $conn){    die(‘连接失败:‘ . mysqli_error($conn));}echo ‘连接数据库成功!!!‘;mysqli_select_db($conn,‘viewtest‘);mysqli_close($conn);?>[[email protected] web]#


1.

2.

DBA: Multiple ways to select MySQL database

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.