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?