mysql-shell的安装和使⽤
mysql-shell是⼀个⾼级的mysql命令⾏⼯具、它直接两种模式(交互式&批处理式)三种语⾔(javascript\python\sql)1、下载地址
sql/downloads/shell/
2、安装安装⽅法就⽐较简单了,下载⼀个linux-general版本的解压就⾏
mysql-shell-1.0.8-rc-linux-glibc2. -C /usr/local/
ln -s /usr/local/mysql-shell-1.0.8-rc-linux-glibc2.12-x86-64bit /usr/local/mysqlsh
export PATH=/usr/local/mysqlsh/bin/:$PATH
3、通过mysql-shell连接到mysql-server
mysqlsh 'appuser'@'127.0.0.1':3306ucgui
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.8-rc
Copyright (c) 2016, 2017, 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':3306 --password=123456
cluster配置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.8-rc
Copyright (c) 2016, 2017, 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':3306/tempdb --password=123456
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.8-rc
Copyright (c) 2016, 2017, 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':'123456'@'127.0.0.1':3306/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.8-rc
Copyright (c) 2016, 2017, 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>
javascript和mysql菜鸟教程4、连接字符串的能⽤格式
mysqlsh [dbuser[:[dbpassword]]@]host[:port][/schema]
5、应⽤举例
假设我要执⾏如下的select 语句、在mysqlsh中我要怎么做呢?
mysql -uroot -e"select * from tempdb.student" -vt
--------------
select * from tempdb.student
-
-------------
+------+
| x |
+------+
javase环境变量配置| 1 |
| 2 |
+------+
在mysqlsh中要⽤如下的⽅式执⾏
mysqlsh --uri 'appuser':'123456'@'127.0.0.1':33060
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.8-rc
Copyright (c) 2016, 2017, 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 |
+---+
| 1 |
| 2 |设置div滚动条
+---+
总结:
就⽬前的情况来说mysqlsh是⼀个数据库初学者的⼯具(会javascript,python不太精通SQL),像资深的DBA应该还是⽤不太着的。 我个⼈感觉mysqlsh对⼀个dba来说并没有mysql这个客户端⼯具来的⽅便。
----
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论