更多文章,欢迎关注作者公众号,欢迎一起交流。

1 MySQL Shell 安装

1)下载安装文件,并上传至数据库服务器

[root@serverc ~]# ls mysql-shell-commercial-8.0.28-linux-glibc2.12-x86-64bit.tar.gzmysql-shell-commercial-8.0.28-linux-glibc2.12-x86-64bit.tar.gz

2)解压缩至 /usr/local/ 目录

[root@serverc local]# cd /usr/local/[root@serverc local]# tar zxvf /root/mysql-shell-commercial-8.0.28-linux-glibc2.12-x86-64bit.tar.gz[root@serverc local]# ln -s mysql-shell-commercial-8.0.28-linux-glibc2.12-x86-64bit/ mysql-shell

3)增加环境变量至.bash_profile文件

[root@serverc local]# echo "export PATH=$PATH:/usr/local/mysql-shell/bin" >> /root/.bash_profile[root@serverc local]# . /root/.bash_profile

4)启动MySQL Shell检查安装和路径配置

[root@serverc local]# mysqlshMySQL Shell 8.0.28-commercialCopyright (c) 2016, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its affiliates.Other names may be trademarks of their respective owners.Type '\help' or '?' for help; '\quit' to exit.MySQL JS >

启动MySQL Shell,默认是JavaScript模式,可以切换到sql、py模式。

2 MySQL Shell 命令

MySQL Shell提供了一系列的命令用于对MySQL数据库进行管理:

命令

别名

描述

\help

\h 或 \?

打印帮助信息

\quit

\q 或\exit

推出MySQL Shell

\

开启SQL模式下的多行模式

\status

\s

显示当前MySQL Shell的状态

\js

切换到javascript执行模式

\py

切换到Python执行模式

\sql

切换到SQL执行模式

\connect

\c

连接MySQL实例

\reconnect

重连MySQL实例

\disconnect

断开MySQL连接

\use

\u

指定要使用的Schema

\source

\. 或 source

执行脚本文件

\warnings

\W

显示语句产生的警告信息

\nowarnings

\w

不显示语句产生的警告信息

\history

查看和编辑历史命令

\rehash

手动更新自动名字缓存

\option

查询和更改MySQL Shell配置选项

\show

使用提供的选项和参数运行特定的报告

\watch

使用提供的选项和参数运行特定的报告,并可按照指定的间隔进行刷新结果

\edit

\e

在默认的系统编辑器中打开命令

\page

\P

分页配置

\nopager

不进行分页

\system

\!

运行操作系统命令

3 创建Sandbox实例

1)登录 MySQL Shell ,可通过\help dba查询帮助信息

[root@serverc local]# mysqlshMySQL Shell 8.0.28-commercialCopyright (c) 2016, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its affiliates.Other names may be trademarks of their respective owners.Type '\help' or '?' for help; '\quit' to exit.MySQL JS > \help dba

2)部署 Sandbox 实例

MySQL JS > dba.deploySandboxInstance(3307);A new MySQL sandbox instance will be created on this host in/root/mysql-sandboxes/3307Warning: Sandbox instances are only suitable for deploying andrunning on your local machine for testing purposes and are notaccessible from external networks.Please enter a MySQL root password for the new instance: ******Deploying new MySQL instance...Instance localhost:3307 successfully deployed and started.Use shell.connect('root@localhost:3307') to connect to the instance.。

3)连接 Sandbox 实例

MySQL JS > \connect root@localhost:3307Creating a session to 'root@localhost:3307'Please provide the password for 'root@localhost:3307': ******Save password for 'root@localhost:3307'? [Y]es/[N]o/Ne[v]er (default No): yFetching schema names for autocompletion... Press ^C to stop.Your MySQL connection id is 12Server version: 8.0.28-commercial MySQL Enterprise Server - CommercialNo default schema selected; type \use to set one.

4)查看 Sandbox 实例状态

MySQL localhost:3307 ssl JS > \sMySQL Shell version 8.0.28-commercialConnection Id: 12Current schema:Current user: root@localhostSSL: Cipher in use: TLS_AES_256_GCM_SHA384 TLSv1.3Using delimiter: ;Server version: 8.0.28-commercial MySQL Enterprise Server - CommercialProtocol version: Classic 10Client library: 8.0.28Connection: localhost via TCP/IPTCP port: 3307Server characterset: utf8mb4Schema characterset: utf8mb4Client characterset: utf8mb4Conn. characterset: utf8mb4Result characterset: utf8mb4Compression: DisabledUptime: 48.0000 secThreads: 2 Questions: 27 Slow queries: 0 Opens: 196 Flush tables: 3 Open tables: 112 Queries per second avg: 0.562MySQL localhost:3307 ssl JS >

5)停止 Sandbox 实例

MySQL localhost:3307 ssl JS > dba.stopSandboxInstance(3307);The MySQL sandbox instance on this host in3307 will be stoppedPlease enter the MySQL root password for the instance 'localhost:3307': ******The active session is established to the sandbox being stopped so it's going to be closed.Stopping MySQL instance...Instance localhost:3307 successfully stopped.

6)启动 Sandbox 实例

MySQL JS > dba.startSandboxInstance(3307);Starting MySQL instance...Instance localhost:3307 successfully started.

以上就是关于MySQL Shell的安装与基本使用。

MySQL Shell 安装与基本使用相关推荐

  1. 【MySQL笔记】mysql来源安装/配置步骤和支持中国gbk/gb2312编码配置

    不久的学习笔记.分享.我想有很大的帮助谁刚开始学习其他人的 备注:该票据于mysql-5.1.73版本号例如 1. mysql源代码编译/安装步骤 1) 官网下载mysql源代码并解压 2) cd至源 ...

  2. lnmp shell安装脚本

    LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构.LNMP是现在大多数大型公司在用的web环境,nginx小巧高效的web服务器和反向代理服务器,相对于apach占 ...

  3. nagios+mysql+ndo2安装总结

    1.apache 安装 1.1下载 http://httpd.apache.org/download.cgi 1.2安装 tar zvxf httpd-2.2.6.tar.gz cd httpd-2. ...

  4. mysql cluster 安装_MYSQL Cluster安装攻略

    1. 为mysqld增加一个登录用户和组:--5个节点都要做此步骤 shell> groupadd mysql shell> useradd -g mysql mysql 2.安装管理节点 ...

  5. linux学习笔记4:linux的任务调度,进程管理,mysql的安装和使用,ssh工具的使用,linux网络编程...

    1.设置任务调度命令crontab 任务调度是指系统在某个时间执行的特定的命令或程序.任务调度分为:1)系统工作:有些重要的工作必须周而复始的执行,如病毒扫描.2)个别用户工作:个别用户可能希望执行某 ...

  6. mysql编译安装后目录空_MySQL源码安装完成后修改安装路径启动问题

    在Linux上源码编译安装完mysql后,又将安装的路径进行了修改,但是发现在设置后环境变量后启动报错,如下: [root@HServer_03 var]# mysqld_safe --user=my ...

  7. mysqldb mysql config,安装mysqldb python界面时找不到mysql_config

    mySQLdb是一个用于mysql的python界面,但它不是mysql本身. 显然mySQLdb需要命令"mysql_config",所以你需要先安装. 你能否确认你是否通过从s ...

  8. mysql数据库安装在unix_Linux下的数据库二:在Linux/Unix平台安装MySQL

    推荐使用RPM工具来进行Linux下的MySQL数据库安装.目前的MySQL rpm安装文件包是在SuSE Linux 7.3系统平台上打造而成的,但是在绝大多数支持RPM和glibc的其他Linux ...

  9. MYSQL数据库安装记

    这回安装数据库装,做下记录. 1.下载mysql源安装包 shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8 ...

  10. 运维自动化之使用PHP+MYSQL+SHELL打造私有监控系统(五)

    4.监控视图 主要是通过shell脚本进行收集mysql的数据,然后同gnuplot软件进行数据视图化,然后php加载这些图片到web里显示,用到的php文件为view.php day.php.mon ...

最新文章

  1. 小虎计算器-技术支持
  2. 信息工程大学806自主命题2020年回忆版真题2020年信息工程大学,初试806回忆版
  3. JAVA中操作符的优先级
  4. Keras【Deep Learning With Python】实现多元线性回归
  5. mysql 5.x数据库安装_Ubuntu 12.04 mysql 源码安装--mysql.5.5.x
  6. 联想e470无线网卡驱动_笔记本显示已关闭无线功能,请问怎样打开?谢谢!
  7. Spring Boot Actuator:自定义端点,其顶部具有MVC层
  8. [转载] Java中变量与常量
  9. 升级python到2.7版本pip不可用
  10. 通信信号与系统分析(一)
  11. Win10保护眼睛豆沙绿背景
  12. python属于低级语言还是高级语言,【单选题】Python语言属于 A. 机器语言 B. 汇编语言 C. 高级语言 D. 科学计算语言...
  13. 【生活中的逻辑谬误】以暴制暴和压制理性
  14. 山西台达plc可编程控制器_汇川PLC可编程控制器的功能特点
  15. linux 删除开机密码,6种清除开机密码方法,总有一个适合你
  16. 修改数据库长度mysql_mysql 修改数据库长度
  17. m3u8\ts片段文件解密合成转换
  18. Android 选择图片、上传图片之Matisse
  19. 找工作面试会遇到哪些坑(校招篇)
  20. 黑苹果OC配置工具:OpenCore Configurator for Mac(2.48.0.0中文)

热门文章

  1. Making Pre-trained Language Models Better Few-Shot Learners
  2. 2014 你好,再见
  3. css 设置层级关系,css层级关系怎么设置
  4. 用猎头的方式来找工作
  5. python怎么计算ord函数_python ord函数
  6. Win10系统文件名太长导致无法删除
  7. 一分钟学会接网线(网络传输介质详解及布线连接)
  8. ESP32 入门笔记06: WIFI时钟 + FreeRTOS+《两只老虎》 (ESP32 for Arduino IDE)
  9. 几种 FPGA 芯片的工艺结构
  10. mybatis 3.x 缓存Cache的使用