1.(MySQL Router+MGR)MySQL Shell安装与用法

环境

MySQL5.7.20 + MyShell8.0.13+Redhat7.3

安装:

yum -y install mysql-shell-8.0.13-1.el7.x86_64.rpm

IP配置:

192.168.136.128  wn19testcdb1001
192.168.136.129  wn19testcdb1002
192.168.136.130  wn19testcdb1003

Using MySQL as a Document Store

mysqlsh -uroot -pRoot@123 -D test MySQL localhost:33060+ test JS > db <Schema:test>

安装X plugin插件:

安装X plugin插件:

需要创建用户:

CREATE USER IF NOT EXISTS mysqlxsys@localhost IDENTIFIED WITH mysql_native_password AS 'password' ACCOUNT LOCK;

GRANT SELECT ON mysql.user TO mysqlxsys@localhost;

GRANT SUPER ON . TO mysqlxsys@localhost;

安装X plugin:

mysql -u root -p INSTALL PLUGIN mysqlx SONAME 'mysqlx.so';

mysqlsh -u root --sqlc -e "show plugins" --socket=/home/db/mysql/mysql.sock

执行一下更新:

Important The mysql.session user must exist before you can load X Plugin. mysql.session was added in MySQL version 5.7.19. If your data dictionary was initialized using an earlier version you must run the mysql_upgrade procedure. If the upgrade is not run, X Plugin fails to start with the error message There was an error when trying to access the server with user: mysql.session@localhost. Make sure the user is present in the server and that mysql_upgrade was ran after a server update..

mysql_upgrade -u root -p --socket=/home/db/mysql/mysql.sock

mysqlx协议登录:

mysql@wn19testcdb1001:/home/db/mysql$ mysqlsh mysqlx://root@localhost:13306/test

Creating an X protocol session to 'root@localhost:13306/test'

Please provide the password for 'root@localhost:13306': ******** MySQL Error 2027: Requested session assumes MySQL X Protocol but 'localhost:13306' seems to speak the classic MySQL protocol (Unexpected response received from server )

\connect用法:

mysql-js> \connect mysqlx://user@localhost:33060

mysql-js> shell.connect('mysqlx://root@localhost:33060/test')

mysqlsh -u user -h localhost --classic --dba enableXProtoco

mysqlsh -u root -h localhost --classic --dba test --socket=/home/db/mysql/mysql.sock

激活XProtoco mysqlsh -u root -h localhost --classic --dba enableXProtocol --socket=/home/db/mysql/mysql.sock

var mysession1=mysqlx.getSession('root@localhost:33060', 'Root@123');

mysqlx.getSession('root:Root@123@localhost');

var mysqlx = require('mysqlx').mysqlx; require('mysqlx');

var mySchema = session.getSchema('test')

mysqlx.getSession('[email protected]:33060', 'Root@123'); mysqlx.getSession({host:'localhost',port:33060,dbUser:'root',dbPassword:'Root@123'});

var mysession1=mysqlx.getSession('root@localhost:33060', 'Root@123');

var result = mySession.world_x.countryinfo.find().execute();

var record = result.fetchOne();

while(record){ print(record); record = result.fetchOne(); }

mysqlx.Session.dropCollection("test","flags")

mysqlsh --log-level=DEBUG3 日志位置 ~/.mysqlsh/mysqlsh.log

dba.configureLocalInstance('[email protected]:13306');

dba.configureLocalInstance('[email protected]:13306');

用MySQL Shell登录:

mysqlsh root@localhost/test --socket=/home/db/mysql/mysql.sock

mysqlsh模式切换\sql \js \py \connect用法:

mysql-js> \connect mysqlx://user@localhost:33060

mysql-js> shell.connect('mysqlx://root@localhost:33060/test')

MySQL JS > \c root@localhost:13306

Creating a session to 'root@localhost:13306' Please provide the password for 'root@localhost:13306': ******** Save password for 'root@localhost:13306'? [Y]es/[N]o/Ne[v]er (default No): N Fetching schema names for autocompletion... Press ^C to stop. Your MySQL connection id is 47 Server version: 5.7.20-log MySQL Community Server (GPL) No default schema selected; type \use <schema> to set one. MySQL localhost:13306 JS > MySQL localhost:13306 JS > session <ClassicSession:root@localhost:13306>

mysqlsh --uri root@localhost:13306 --user root

mysqlsh --mysqxl -u root -h localhost -P 13306

mysqlsh --mysql -u root -h localhost --socket=/home/db/mysql/mysql.sock

var mysession1=mysqlx.getSession('root@localhost:13306', 'Root@123');

session

shell.connect('mysqlx://user@localhost:33060')

MySQL localhost:13306 JS > session.uri mysql://root@localhost:13306

mysqlsh root@localhost/test --socket=/home/db/mysql/mysql.sock

var mySchema = session.getSchema('test')

发布了117 篇原创文章 · 获赞 20 · 访问量 33万+

猜你喜欢

转载自blog.csdn.net/u010719917/article/details/86646801