【MySQL Shell】MySQL Shell体验
二进制包下载:https://downloads.mysql.com/archives/shell/
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select user,host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)
MySQL需要新增root@"127.0.0.1"用户,权限与root@localhost相同。
下载软件包: mysql-shell-8.0.27-linux-glibc2.12-x86-64bit.tar.gz
$tar -Jxf mysql-shell-8.0.27-linux-glibc2.12-x86-64bit.tar.gz
$ cd mysql-shell-8.0.27-linux-glibc2.12-x86-64bit/bin/
$ ls
mysql-secret-store-login-path mysqlsh
$ ./mysqlsh
MySQL Shell 8.0.27
Copyright (c) 2016, 2021, 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 >
shell中连接指定用户端口
$ ./mysqlsh root@localhost:3306
#连接到指定数据库
MySQL localhost:3306 ssl JS > \use mysql
Default schema set to `mysql`.
MySQL localhost:3306 ssl mysql JS > \s
MySQL Shell version 8.0.27
Connection Id: 40
Current schema: mysql
Current user: root@127.0.0.1
SSL: Cipher in use: TLS_AES_256_GCM_SHA384 TLSv1.3
Using delimiter: ;
Server version: 8.0.27 MySQL Community Server - GPL
Protocol version: Classic 10
Client library: 8.0.27
Connection: localhost via TCP/IP
TCP port: 3306
Server characterset: utf8mb4
Schema characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
Result characterset: utf8mb4
Compression: Disabled
Uptime: 43 min 14.0000 sec
Threads: 2 Questions: 85 Slow queries: 0 Opens: 1086 Flush tables: 3 Open tables: 104 Queries per second avg: 0.032
MySQL localhost:3306 ssl mysql JS >
shell中连接指定数据库
$ ./mysqlsh root@localhost:3306/mysql