1. (MySQL Router + MGR) MySQL Shell Installation and Usage

surroundings

MySQL5.7.20 + MyShell8.0.13+Redhat7.3

installation:

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

IP configuration:

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 installed plug-ins:

X plugin installed plug-ins:

You need to create a user:

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;

Installation 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

Implementation of some updates:

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 agreement Login:

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 Usage:

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();

Recordings were result.fetchOne = ();

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

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

mysqlsh --log-level = DEBUG3 log location ~ / .mysqlsh / mysqlsh.log

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

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

Login using MySQL Shell:

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

mysqlsh mode switching \ sql \ js \ py \ connect usage:

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')

Published 117 original articles · won praise 20 · views 330 000 +

Guess you like

Origin blog.csdn.net/u010719917/article/details/86646801