需求描述

  mysql客户端,可以在登录到mysql数据库时,指定要连接到哪个数据库

  这里进行一个测试。

测试过程:

1.mysql通过-D参数指定连接到test数据库

[mysql@redhat6 scripts]$ mysql -uroot -p -D test
Enter password:
ERROR (): Access denied for user 'root'@'localhost' (using password: YES)
[mysql@redhat6 scripts]$ mysql -uroot -p -D test
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
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 its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select database();
+------------+
| database() |
+------------+
| test |
+------------+
row in set (0.00 sec)

备注:通过在-D参数后面指定数据库名字,就连接到了test数据库。

2.通过-D参数,连接到test01数据库

[mysql@redhat6 scripts]$ mysql -uroot -p -D test01
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
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 its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select database();
+------------+
| database() |
+------------+
| test01 |
+------------+
row in set (0.00 sec) mysql>

备注:通过在-D参数后面指定数据库名字,就连接到了test01数据库。

小结:通过-D 参数指明要直接连接到哪个数据库。

文档创建时间:2018年3月20日11:37:27

mysql在命令行中,指定要连接的数据库?的更多相关文章

  1. Windows命令行中使用SSH连接Linux

    转自 http://www.linuxidc.com/Linux/2014-02/96625.htm 1.下载: openssh for Winodws: 免费下载地址在 http://linux.l ...

  2. mysql中如何在命令行中,执行一个SQL脚本文件?

    需求描述: 在mysql数据库的使用中,有的时候,需要直接在shell的命令行中,执行某个SQL脚本文件, 比如,要初始化数据库,创建特定的存储过程,创建表等操作,这里进行一个基本的测试. 一般情况, ...

  3. 转 mysql mysql命令行中执行sql的几种方式总结

    https://www.jb51.net/article/96394.htm 1.直接输入sql执行 MySQL> select now(); +---------------------+ | ...

  4. 命令行中mysql乱码问题

    1.现象  在命令行中,执行sql语句如果包含中问题,提示“ Data too long for column '列名' at row 1”   或者在命令行中查询出的结果中,中文乱码   2.分析 ...

  5. Mysql常用命令行大全(三)

    /**操作数据库*/ SHOW DATABASES; CREATE DATABASE db; SHOW DATABASES; DROP DATABASE db; /**操作表*/ USE  db; S ...

  6. php开发面试题---Mysql常用命令行大全

    php开发面试题---Mysql常用命令行大全 一.总结 一句话总结: 常见关键词:create,use,drop,insert,update,select,where ,from.inner joi ...

  7. 命令行中使用adb安装apk

    转载:http://blog.sina.com.cn/s/blog_8324d8e80101b8dn.html 在你的android—IDE中找到D:\Softwave_Ghost\技术软件\IDE\ ...

  8. 在 Linux/windows下 命令行中使用和执行 PHP 代码[交互式php]

    [注释]在ubuntu下,升级php到7.1版本,虽然提示的是Interactive mode enabled, 但实际上可以直接书写命令,和interactive shell效果一样. 一:wind ...

  9. (转)Mysql常用命令行

    原文:http://www.cnblogs.com/TsengYuen/archive/2012/01/11/2319034.html Mysql常用命令行 Mysql经常使用号令行大全 熬头招.my ...

随机推荐

  1. Python 里 and、or 的计算规则

    引子: >>> print '' or 5 or 05>>> print 5 and 44>>> print '' or 5 or 0 and 4 ...

  2. MySQL常见的库操作,表操作,数据操作集锦及一些注意事项

    一 库操作(文件夹) 1 数据库命名规则 可以由字母.数字.下划线.@.#.$ 区分大小写 唯一性 不能使用关键字如 create select 不能单独使用数字 最长128位 2 数据库相关操作 创 ...

  3. Python+Django+js+echarts引入本地js文件的操作方法

    1. 选择正确的echarts.js,开发版选择echarts.baidu.com上的源码版,避免出现问题 2. 在项目主目录中新建static文件夹,里面建立js.css.images文件夹 3. ...

  4. LeetCode: Clone Graph 解题报告

    Clone GraphClone an undirected graph. Each node in the graph contains a label and a list of its neig ...

  5. 基于jQuery在线问卷答题系统代码

    分享一款基于jQuery在线问卷答题系统代码是一款实用的jQuery答题插件,点击下一题切换带有淡入淡出效果.实现的效果图如下: 在线预览   源码下载 实现的代码. html代码: <div ...

  6. ospf动态路由配置(单区域)

    命令: Router(config-router)#network 目标网络号 反子网掩码 area 区域号 示例: Router(config-router)#network 10.2.2.0 0. ...

  7. SQL server 2005如何设置一个或几个字段唯一约束?

    --建立是在三个字段上的唯一约束 alter table Tab add constraint uq_id unique(shipType, shipsession, Territory)

  8. maven_nexus3私服搭建

    [maven_nexus3私服搭建] # 00.安装环境说明# (1)Windows7 64位# (2)JDK1.8 64位# (3)Sonatype Nexus Repository OSS 3.1 ...

  9. 华为console口配置

    c.单击“Connect”,终端界面会出现如下显示信息,提示用户配置登录密码.设备缺省用户名为admin,密码为Admin@huawei.(以下显示信息仅为示意) user-interface con ...

  10. LNMP环境下SendMail+OpenWebMail的详细配置

    随着网络的发展和普及,邮件服务器正在成为人们日常生活中不可缺少的部分.现在,许多企业采用 Lotus Note, Exchange 作为公司内部的邮件服务器.本文主要介绍一种基于Linux系统的邮件服 ...