mysql在命令行中,指定要连接的数据库?
需求描述:
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在命令行中,指定要连接的数据库?的更多相关文章
- Windows命令行中使用SSH连接Linux
转自 http://www.linuxidc.com/Linux/2014-02/96625.htm 1.下载: openssh for Winodws: 免费下载地址在 http://linux.l ...
- mysql中如何在命令行中,执行一个SQL脚本文件?
需求描述: 在mysql数据库的使用中,有的时候,需要直接在shell的命令行中,执行某个SQL脚本文件, 比如,要初始化数据库,创建特定的存储过程,创建表等操作,这里进行一个基本的测试. 一般情况, ...
- 转 mysql mysql命令行中执行sql的几种方式总结
https://www.jb51.net/article/96394.htm 1.直接输入sql执行 MySQL> select now(); +---------------------+ | ...
- 命令行中mysql乱码问题
1.现象 在命令行中,执行sql语句如果包含中问题,提示“ Data too long for column '列名' at row 1” 或者在命令行中查询出的结果中,中文乱码 2.分析 ...
- Mysql常用命令行大全(三)
/**操作数据库*/ SHOW DATABASES; CREATE DATABASE db; SHOW DATABASES; DROP DATABASE db; /**操作表*/ USE db; S ...
- php开发面试题---Mysql常用命令行大全
php开发面试题---Mysql常用命令行大全 一.总结 一句话总结: 常见关键词:create,use,drop,insert,update,select,where ,from.inner joi ...
- 命令行中使用adb安装apk
转载:http://blog.sina.com.cn/s/blog_8324d8e80101b8dn.html 在你的android—IDE中找到D:\Softwave_Ghost\技术软件\IDE\ ...
- 在 Linux/windows下 命令行中使用和执行 PHP 代码[交互式php]
[注释]在ubuntu下,升级php到7.1版本,虽然提示的是Interactive mode enabled, 但实际上可以直接书写命令,和interactive shell效果一样. 一:wind ...
- (转)Mysql常用命令行
原文:http://www.cnblogs.com/TsengYuen/archive/2012/01/11/2319034.html Mysql常用命令行 Mysql经常使用号令行大全 熬头招.my ...
随机推荐
- 我为什么鼓励程序员写blog
工程师该怎样才能突破自己的能力瓶颈?写 blog! 工程师该怎样精进自己在职涯上所需要的能力?写 blog! 工程师该怎样才能保持学习与成长的动能?写 blog! 工程师该怎样才能证明自己的潜力与特质 ...
- 請問 localtime() 為什麼不會造成 memory leak?
http://www.programmer-club.com.tw/ShowSameTitleN/vc/22380.html ************************************* ...
- js添加收藏夹
<a href="JavaScript:window.external.AddFavorite('http://baidu.com','百度')"> 添加到收藏夹 &l ...
- System.Data.SqlClient.SqlError:无法打开备份设备'D:\..\abc.bak'
在SQL Server中备份数据库时遇到备份对于服务器“服务器名”失败. (Microsoft.SqlServer.Smo)其他信息:System.Data.SqlClient.SqlError:无法 ...
- LeetCode: Maximal Rectangle 解题报告
Maximal RectangleGiven a 2D binary matrix filled with 0's and 1's, find the largest rectangle contai ...
- J2EE面试题集锦_
一.基础问答 不能被继承的类有[Long Double Float Short Void Class Math String] 他们都被final修饰 类可以被继承[Th ...
- 基于html5整屏切换IDO智能手表页面滚动代码
之前为大大家介绍了一款jquery实现的整屏切换特效.今天分享一款IDO智能手表页面滚动html5代码.这是一款基于jQuery+HTML5实现的页面滚动效果代码.效果图如下: 在线预览 源码下载 ...
- 一款纯css3实现的动画加载导航
之前为大家介绍了好几款导航菜单,今天为给大家再带来一款纯css3实现的动画加载导航.该导航出现的时候以动画的形式出现.效果图如下: 在线预览 源码下载 实现的代码. html代码: <ul ...
- Excel最多可存多少行,多少列?
查到的资料如下: Excel 07-2003一个工作表最多可有65536行,行用数字1—65536表示;最多可有256列,列用英文字母A—Z,AA—AZ,BA—BZ,……,IA—IV表示:一个工作簿中 ...
- CodeIgniter(3.1.4)框架中-使用多个公共控制器
项目目录结构: 在core/MY_Controller.php文件下: <?php /** * Class MY_Controller * 自定义控制器 */ class MY_Controll ...