需求描述

  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. cocos2d-x -- removeChild

    Test5::Test5() { CCSprite* sp1 = CCSprite::create(s_pPathSister1); CCSprite* sp2 = CCSprite::create( ...

  2. flask celery 使用方法

    一.安装 由于celery4.0不支持window,如果在window上安装celery4.0将会出现下面的错误flask_clery 你现在只能安装pip install celery==3.1 二 ...

  3. nrm 的使用说明

    nrm -- NPM registry 管理工具 开发的npm registry 管理工具 nrm, 能够查看和切换当前使用的registry, 最近NPM经常 down 掉, 这个还是很有用的哈哈 ...

  4. 交叉编译busybox

    交叉编译器: 3.3.2# wget -c http://www.busybox.net/downloads/busybox-1.7.0.tar.bz2# tar jxvf busybox-1.7.0 ...

  5. spring 在service中需要抛出异常才能自动回滚

    在spring 事务配置中,如果service方法捕获了异常,则程序报错也不会自动回滚, 1.手动开启关闭事务 2.抛出异常,可以先捕获异常,然后自定义runtime异常,可不用声明

  6. .NET项目web自动化测试实战——Selenium 2.0

    PS:这次用公司的项目来练手,希望公司不会起诉我,因为我绝对是抱着学习的态度,没有任何恶意.仅供交流学习. 该项目是基于SharePoint平台所开发的门户网站,为了切身感受一下Selenium 2. ...

  7. zoj3228 Searching the String AC自动机查询目标串中模式串出现次数(分可覆盖,不可覆盖两种情况)

    /** 题目:zoj3228 Searching the String 链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=34 ...

  8. SpringMVC经典系列-15对SpringMVC的总结---【LinusZhu】

    注意:此文章是个人原创,希望有转载须要的朋友们标明文章出处,假设各位朋友们认为写的还好,就给个赞哈.你的鼓舞是我创作的最大动力,LinusZhu在此表示十分感谢,当然文章中如有纰漏,请联系linusz ...

  9. 清除DataGridView显示的数据

    一.DataGridView未绑定数据时清空数据 this.dgv_PropDemo.DataSource = null 二.DataGridView绑定数据时清空数据 DataGridView绑定了 ...

  10. @Configuration和@Bean的用法和理解

    spring Boot提倡约定优于配置,如何将类的生命周期交给spring 1.第一种自己写的类,Controller,Service. 用@controller @service即可 2.第二种,集 ...