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监听不同的 ...
随机推荐
- 搭建maven支持的web工程的步骤
搭建一个新的web project的整体思路:先用maven搭建项目的骨架,生成mvn project,然后将mvn project转换为web project,最后添加相关的Spring,hiber ...
- HDU 1507 Uncle Tom's Inherited Land*(二分匹配,输出任意一组解)
Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- iOS:判断用户名是否以字母开头、手机号输入、邮箱是否正确的正则表达式
新建一个字符串分类:NSString(Check),定义类方法更方便 .h文件 #import <Foundation/Foundation.h> @interface NSString ...
- iOS:quartz2D绘图小项目(涂鸦画板)
介绍:学了quartz2D的绘图知识后,我根据它的一些功能制作了一个小项目:涂鸦画板. 功能:绘制各种图形,还可以选取相册上的照片做涂鸦,然后保存到相册中.其中,还包括功能有:颜色的选取.线宽的选取. ...
- LINUX提权笔记
没啥技术含量,一种思路,让某些得到root权限webshell的童鞋可以快点拿到权限. 某日拿到某站webshell,RedHat 系统,Tomcat程序是root身份启动的,webshell当然也拥 ...
- Oracle两个时间段是否重合、冲突
经常会碰到比较两个时间段是否冲突的情况. 思路1 最开始比较2个时间是否的思路是,时间段的重叠. 但是比较时间段重叠的情况,就有几种情况, 1. 时间前段冲突. 时间A: 2015-10-01 ...
- [Functional Programming ADT] Create State ADT Based Reducers (applyTo, Maybe)
The typical Redux Reducer is function that takes in the previous state and an action and uses a swit ...
- 实时视频直播客户端技术盘点:Native、HTML5、WebRTC、微信小程序
1.前言 2017 年 12 月,微信小程序向开发者开放了实时音视频能力,给业内带来广阔的想象空间.连麦互动视频直播技术在 2016 年直播风口中成为视频直播的标配,然而只有在原生的 APP 上才能保 ...
- vue - webpack.dev.conf.js for merge
webpack-merge提供了一个merge连接数组并合并创建新对象的对象的函数.如果遇到函数,它将执行它们,通过算法运行结果,然后再次将返回的值包装在函数中. 这种行为在配置webpack时特别有 ...
- 移动端(阿里rem)布局
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...