MySQL on the command line, specify the database to connect to?

Source: Internet
Author: User
Tags mysql client reserved

Requirements Description :

MySQL client, you can specify which database to connect to when you log in to the MySQL database

Here is a test.

Test process:

1.mysql specifying the connection to the test database with the-d parameter

[Email protected] scripts]$ mysql-uroot-p-D testenter password:error1045(28000): Access denied forUser'Root'@'localhost'(using Password:yes) [[email protected] scripts]$ MySQL-uroot-p-D Testenter Password:welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connectionIDIs -Server Version:5.5. $-log MySQL Community Server (GPL) Copyright (c) -, -, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or Itsaffiliates. Other names trademarks of their respectiveowners. Type'Help ;'Or'\h'  forHelp. Type'\c'ToClearThe current input statement.mysql>Selectdatabase ();+------------+| Database () |+------------+| Test |+------------+1RowinchSet (0.00Sec

Note: You connect to the test database by specifying the database name after the-d parameter.

2. Connect to the TEST01 database via the-D parameter

[Email protected] scripts]$ mysql-uroot-p-D Test01enter Password:welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connectionIDIs theServer Version:5.5. $-log MySQL Community Server (GPL) Copyright (c) -, -, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or Itsaffiliates. Other names trademarks of their respectiveowners. Type'Help ;'Or'\h'  forHelp. Type'\c'ToClearThe current input statement.mysql>Selectdatabase ();+------------+| Database () |+------------+| test01 |+------------+1RowinchSet (0.00sec) MySQL>

Note: You connect to the TEST01 database by specifying the database name after the-d parameter.

Summary : Use the-d parameter to indicate which database you want to connect directly to.

Document creation time: March 20, 2018 11:37:27

MySQL on the command line, specify the database to connect to?

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.