mysql-shell是一个高级的mysql命令行工具、它直接两种模式(交互式&批处理式)三种语言(javascript\python\sql)

1、下载地址

https://dev.mysql.com/downloads/shell/

2、安装 安装方法就比较简单了,下载一个linux-general版本的解压就行

mysql-shell-1.0.-rc-linux-glibc2.-x86-64bit.tar.gz  -C /usr/local/
ln -s /usr/local/mysql-shell-1.0.-rc-linux-glibc2.-x86-64bit /usr/local/mysqlsh
export PATH=/usr/local/mysqlsh/bin/:$PATH

3、通过mysql-shell连接到mysql-server

mysqlsh 'appuser'@'127.0.0.1':
Creating a Session to 'appuser@127.0.0.1:3306'
Enter password:
Classic Session successfully established. No default schema selected.
Welcome to MySQL Shell 1.0.-rc 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', '\h' or '\?' for help, type '\quit' or '\q' to exit. Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
mysql-js>

第每连接都要输入密码、就是不喜欢、好在可以直接指定它

mysqlsh 'appuser'@'127.0.0.1': --password=
mysqlx: [Warning] Using a password on the command line interface can be insecure.
Creating a Session to 'appuser@127.0.0.1:3306'
Classic Session successfully established. No default schema selected.
Welcome to MySQL Shell 1.0.-rc 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', '\h' or '\?' for help, type '\quit' or '\q' to exit. Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
mysql-js>

除了这个之处还可以在连接字符串中指定数据库的名字,类似于use dbname;的效果

mysqlsh 'appuser'@'127.0.0.1':/tempdb --password=
mysqlx: [Warning] Using a password on the command line interface can be insecure.
Creating a Session to 'appuser@127.0.0.1:3306/tempdb'
Classic Session successfully established. Default schema set to `tempdb`.
Welcome to MySQL Shell 1.0.-rc 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', '\h' or '\?' for help, type '\quit' or '\q' to exit. Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
mysql-js>

把密码也加到连接字符串中去

mysqlsh 'appuser':''@'127.0.0.1':/tempdb
mysqlx: [Warning] Using a password on the command line interface can be insecure.
Creating a Session to 'appuser@127.0.0.1:3306/tempdb'
Classic Session successfully established. Default schema set to `tempdb`.
Welcome to MySQL Shell 1.0.-rc 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', '\h' or '\?' for help, type '\quit' or '\q' to exit. Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
mysql-js>

4、连接字符串的能用格式

mysqlsh [dbuser[:[dbpassword]]@]host[:port][/schema]

5、应用举例

假设我要执行如下的select 语句、在mysqlsh中我要怎么做呢?

mysql -uroot -e"select * from tempdb.student" -vt
--------------
select * from tempdb.student
-------------- +------+
| x |
+------+
| |
| |
+------+

在mysqlsh中要用如下的方式执行

mysqlsh  --uri 'appuser':''@'127.0.0.1':
mysqlx: [Warning] Using a password on the command line interface can be insecure.
Creating a Session to 'appuser@127.0.0.1:33060'
Node Session successfully established. No default schema selected.
Welcome to MySQL Shell 1.0.-rc 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', '\h' or '\?' for help, type '\quit' or '\q' to exit. Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
mysql-js> \use tempdb
Schema `tempdb` accessible through db.
mysql-js> db.student.select()
+---+
| x |
+---+
| |
| |
+---+

总结:

  就目前的情况来说mysqlsh是一个数据库初学者的工具(会javascript,python不太精通SQL),像资深的DBA应该还是用不太着的。

  我个人感觉mysqlsh对一个dba来说并没有mysql这个客户端工具来的方便。

----

mysql-shell的安装和使用的更多相关文章

  1. shell脚本专题之-----------全自动编译安装mysql(免安装版)

    mysql的编译安装,在博客 开源服务专题之--------mysql的编译安装 中已经说明了,但是还是比较麻烦,尤其是一大堆命令,来手动执行,稍有不慎,就会出错.生产上一般都是先在本地测试环境进行自 ...

  2. 4. 利用MySQL Shell安装部署MGR集群 | 深入浅出MGR

    GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 目录 1. 安装准备 2. 利用MySQL Shell构建MGR集群 3. MySQL Shell接管现存的MGR集群 4 ...

  3. 细说Mysql四种安装方法及自动化部署

    一.简介 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库, 每个数据库都有一个或多个不同的API用于创建,访问,管理,搜索和复制所保存的数据. 我们也可以将数据存储在文件中,但是 ...

  4. mysql cluster (mysql 集群)安装配置方案(转)

    一.准备 1.准备服务器 计划建立有5个节点的MySQL CLuster体系,需要用到5台服务器,但是我们做实验时没有这么多机器,可以只用2台,我就是一台本机,一台虚拟机搭建了有5个节点的MySQL ...

  5. MySQL 5.7.12新增MySQL Shell命令行功能

      在最新发布的MySQL 5.7.12中有许多令人兴奋的新功能,对于MySQL开发者来说,最令人兴奋的莫不是新增的MySQL Shell了,其下载地址: http://dev.mysql.com/d ...

  6. mysql、mariadb安装和多实例配置

    本文目录:1. mysql单实例安装 1.1 rpm安装mysql 1.2 通用二进制包安装mysql 1.2.1 初始化数据库 1.2.2 安装后的规范化操作 1.3 编译安装 1.3.1 编译安装 ...

  7. MySQL数据库下载安装和DataGrip的下载安装和破解

    一: 数据库下载 地址:官网https://dev.mysql.com/downloads/file/?id=482771;如果参数id失效,就选择之前的版本,5.7就可以,太新的没人用,老的很稳定. ...

  8. centos6.5 MySQL数据库的安装

    <div id="home"><div id="header"> <div id="blogTitle"> ...

  9. macOS下MySQL 8.0 安装与配置教程

    一.前言 1.本教程主要内容 适用Homebrew安装MySQL MySQL 8.0 基础适用于配置 MySQL shell管理常用语法示例(用户.权限等) MySQL字符编码配置 MySQL远程访问 ...

  10. linux下mysql多实例安装

    1.MySQL多实例介绍 1.1.什么是MySQL多实例 MySQL多实例就是在一台机器上开启多个不同的服务端口(如:3306,3307),运行多个MySQL服务进程,通过不同的socket监听不同的 ...

随机推荐

  1. HDU 5288 OO’s Sequence 水题

    OO's Sequence 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5288 Description OO has got a array A ...

  2. Educational Codeforces Round 8 C. Bear and String Distance 贪心

    C. Bear and String Distance 题目连接: http://www.codeforces.com/contest/628/problem/C Description Limak ...

  3. xcode在调试时无法查看变量值

    现象:在xcode中调试程序的时候,无论是鼠标指在变量上,还是在gdb中po命令都看不到内存中变量的值. 解决办法:在Project的Build中把 Optimization Level 设置成 No ...

  4. 错误:Caused by:org.apache.spark.SparkException: Kryo serialization failed: Buffer overflow.Available: 0, required: 21. To avoid this,

    这个是写入Redis时用的序列化器,然后错误提示是超过了大小限制,把配置调大即可. .set("spark.kryoserializer.buffer.max","128 ...

  5. [漏洞检测]Proxpy Web Scan设计与实现(未完待续)

    Proxpy Web Scan设计与实现 1.简介:          Proxpy Web Scan是基于开源的python漏洞扫描框架wapiti改造的web漏洞扫描器,其主要解决以下几个问题而生 ...

  6. ARM体系下的GCC内联汇编

    转:http://andyhuzhill.github.io/arm/gcc/asm/2012/09/25/gcc-inline-assemly/ 在操作系统级的编程中,有时候,C语言并不能完全的使用 ...

  7. Oracle SQL执行缓慢的原因以及解决方案

     以下的文章抓哟是对Oracle SQL执行缓慢的原因的分析,如果Oracle数据库中的某张表的相关数据已是2亿多时,同时此表也创建了相关的4个独立的相关索引.由于业务方面的需要,每天需分两次向此表中 ...

  8. The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path:

    今天下载Windows安装版的tomcat5.5,安装完以后启动时候出现: The Apache Tomcat Native library which allows optimal performa ...

  9. chrome.webRequest

    chrome.webRequest 描述: 使用 chrome.webRequest API 监控与分析流量,还可以实时地拦截.阻止或修改请求.  可用版本: 从 Chrome 17 开始支持.  权 ...

  10. dedecms会员注册注入漏洞

    一.首先访问“/data/admin/ver.txt”页面获取系统最后升级时间,(判断是否是dede的cms 以及看看是否和这个漏洞相对应)二.然后访问“/member/ajax_membergrou ...