mysql-shell的安装和使用
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的安装和使用的更多相关文章
- shell脚本专题之-----------全自动编译安装mysql(免安装版)
mysql的编译安装,在博客 开源服务专题之--------mysql的编译安装 中已经说明了,但是还是比较麻烦,尤其是一大堆命令,来手动执行,稍有不慎,就会出错.生产上一般都是先在本地测试环境进行自 ...
- 4. 利用MySQL Shell安装部署MGR集群 | 深入浅出MGR
GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 目录 1. 安装准备 2. 利用MySQL Shell构建MGR集群 3. MySQL Shell接管现存的MGR集群 4 ...
- 细说Mysql四种安装方法及自动化部署
一.简介 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库, 每个数据库都有一个或多个不同的API用于创建,访问,管理,搜索和复制所保存的数据. 我们也可以将数据存储在文件中,但是 ...
- mysql cluster (mysql 集群)安装配置方案(转)
一.准备 1.准备服务器 计划建立有5个节点的MySQL CLuster体系,需要用到5台服务器,但是我们做实验时没有这么多机器,可以只用2台,我就是一台本机,一台虚拟机搭建了有5个节点的MySQL ...
- MySQL 5.7.12新增MySQL Shell命令行功能
在最新发布的MySQL 5.7.12中有许多令人兴奋的新功能,对于MySQL开发者来说,最令人兴奋的莫不是新增的MySQL Shell了,其下载地址: http://dev.mysql.com/d ...
- mysql、mariadb安装和多实例配置
本文目录:1. mysql单实例安装 1.1 rpm安装mysql 1.2 通用二进制包安装mysql 1.2.1 初始化数据库 1.2.2 安装后的规范化操作 1.3 编译安装 1.3.1 编译安装 ...
- MySQL数据库下载安装和DataGrip的下载安装和破解
一: 数据库下载 地址:官网https://dev.mysql.com/downloads/file/?id=482771;如果参数id失效,就选择之前的版本,5.7就可以,太新的没人用,老的很稳定. ...
- centos6.5 MySQL数据库的安装
<div id="home"><div id="header"> <div id="blogTitle"> ...
- macOS下MySQL 8.0 安装与配置教程
一.前言 1.本教程主要内容 适用Homebrew安装MySQL MySQL 8.0 基础适用于配置 MySQL shell管理常用语法示例(用户.权限等) MySQL字符编码配置 MySQL远程访问 ...
- linux下mysql多实例安装
1.MySQL多实例介绍 1.1.什么是MySQL多实例 MySQL多实例就是在一台机器上开启多个不同的服务端口(如:3306,3307),运行多个MySQL服务进程,通过不同的socket监听不同的 ...
随机推荐
- ArrayList源码及解析
package java.util; import java.util.function.Consumer; import java.util.function.Predicate; import j ...
- [转]jQuery 双击事件(dblclick)时,不触发单击事件(click)
例1: 链接:http://www.w3school.com.cn/jquery/event_dblclick.asp HTML 系列教程 浏览器脚本 服务器脚本 ASP.NET 教程 XML 系列教 ...
- Java原始封装常用HttpRequest
1. package com.jsoft.testjavathread.test1; import java.io.BufferedReader; import java.io.IOException ...
- android基础知识复习——RelativeLayout布局属性、背景、半透明设置(XML设置)
转自:http://blog.csdn.net/fansongy/article/details/6817968 复习布局与XML,写了一个空的登录界面.XML的注释我写在当行的后面了.程序运行图: ...
- 将图片转换为Base64字符串公共类抽取
public class ImageToBase64 { //图片转化成base64字符串 public static String GetImageStr(String path,int width ...
- 基于Nginx的开墙方案
Kubernetes集群内部通过服务名能进行相互调用,但如果Kubernetes中的pod需要调用外部服务,而且这些外部服务是属于不同的安全区域,就面临开墙的问题,因为Kubernetes Pod能够 ...
- You must have a TTY to run sudo
1.方法一,给命令行添加tty ssh -t user@foo.com 2.使用sudo visudo修改配置: Defaults:user !requiretty 表示用户user使用sudo命令时 ...
- Synopsys EDA工具在LinuxMint 18(Ubuntu 16.04.2)安装注意事项
Synopsys家的工具官方对Linux发行版支持为RHEL 5/6/7及SUSE 12/13,对于2014版本的工具(DC.ICC.PT.VCS.HSPICE等).其实,在Debian系及衍生版本上 ...
- linux中断流程详解
异常体系比较复杂,但是linux已经准备了很多的函数和框架,但是因为中断是和具体的开发板相关,所以中断需要我们自己来处理一些方面,但是这也是很少的一部分,很多公用的处理函数内核已经实现,linux内核 ...
- centos7 yum安装redis(转)
正如我们所知的那样,Redis是一个开源的.基于BSD许可证的,基于内存的.键值存储NoSQL数据库.Redis经常被视为一个数据结构服务器,因为Redis支持字符串strings.哈希hashes. ...