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. 关于abstract class 和 interface

    1.abstract class 在 Java 语言中表示的是一种继承关系,一个类只能使用一次继承关系.但是,一个类却可以实现多个interface. 2.在abstract class 中可以有自己 ...

  2. Failed to Attach to Process ID Xcode 解决办法

    方法1. go to the Product menu and find the Edit Scheme menu there. While in Edit Scheme window, select ...

  3. python获取函数名

    Date: 20140223Auth: Jin 参考: http://hi.baidu.com/greysign/item/d11919d325c4c2e6b2f777bf 获取函数名python中获 ...

  4. POJ 3608 Bridge Across Islands(旋转卡壳,两凸包最短距离)

    Bridge Across Islands Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7202   Accepted:  ...

  5. GUN C/C++ __attribute__ 用法 转

     http://blog.csdn.net/mydo/article/details/3738336     GNUC的一大特色(却不被初学者所知)就是__attribute__机制.__attrib ...

  6. JCA 了解

    JCA (J2EE 连接器架构,Java Connector Architecture)是对 J2EE标准集的重要补充.因为它注重的是将 Java程序连接到非Java程序和软件包中间件的开发.连接器特 ...

  7. POI创建Excel使用的常见的属性

    public static void main(String[] args) { //创建新的Excel 工作簿 HSSFWorkbook workbook =new HSSFWorkbook(); ...

  8. redigo简单理解

    package main import ( "fmt" "github.com/gomodule/redigo/redis") func main() { // ...

  9. 【Todo】机器学习系列

    看了这篇文章很好,有很多指导性思想: http://www.cnblogs.com/tornadomeet/p/3395593.html 另外这个人的系列文章里面也有很多干货. 就看这个系列的吧: h ...

  10. MySQL : ERROR 1042 (HY000): Can't get hostname for your address

    摘自: http://www.siutung.org/post/506/ 使用Navicat for MySQL连接远程的MySQL服务器,却提示:Can't get hostname for you ...