「mysql-shell」

  LINUX MANUAL PAGES

MySQL Shell是支持MySQL服务器开发和管理的交互式界面,是MySQL服务器的组件。支持Javascript,Python或SQL,可以使用MySQL Shell来执行数据查询更新以及各种管理操作

安装

可以到官网下载MySQL Shell。我们安装的版本使1.0.9。

详细的安装过程都在源码目录下的INSTALL文件中,这里不再赘述,以下内容取自INSTALL文件,更多细节请阅读INSTALL文件:
Build Instructions for MySQL Shell

需要安装的依赖软件包如下
– cmake
– boost 1.59+,C++库
– libmysqlclient 5.7+
– protobuf 2.6.1
– zip (gnuwin32 in windows)
– python 2.6+
– MySQL Connector Python 2.1.3+ (for Python 2)

可选的依赖软件包
– gtest 1.7,用于单元测试
– v8 3.28.71.19,Javascript引擎,安装v8时要注意版本。

使用源码开始编译

#!/bin/sh

# 1. 进入源码目录
mkdir bld
cd bld
cmake .. -DWITH_PROTOBUF=<path_to_protobuf> -DHAVE_PYTHON=1
make

以这种方式编译出来的MySQL Shell只支持SQL模式。

如果你希望支持Javascript
JavaScript is enabled by satisfying the dependency with V8.
To build V8 follow the build V8 standard build instructions.
To support JavaScript on the MySQL Shell add the next flags to the CMake call:

-DV8_INCLUDE_DIR=<path_to_v8>/include
-DV8_LIB_DIR=<path_to_folder_containing_the_built_libraries>

如果你希望支持Python
Python is enabled by satisfying the dependency with Python.
To support Python on the MySQL Shell add the next flags to the CMake call:

-DHAVE_PYTHON=1

指定MySQL的安装路径
如果MySQL的安装不符合FHS,那你就要手动指定MySQL的安装路径了。
Specify the MySQL to be used (i.e. not the installed one) by adding the next parameter to the cmake call.
-DMYSQL_DIR=<path_to_mysql-folder>
Version 5.7 and above is recommended.
If MySQL is installed CMake may be able to find it even the parameter is not specified.
Use the parameter to specify the path to an uncompressed MySQL package.

安装的程序

mysqlsh
实际上的话,只安装了这一个命令。
不过这一个命令也够你玩的了。

Error List

#1 Curses library not found. Please install appropriate package,

— Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:64 (MESSAGE):
Curses library not found. Please install appropriate package,

remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

Call Stack (most recent call first):

cmake/readline.cmake:107 (FIND_CURSES)

cmake/readline.cmake:181 (MYSQL_USE_BUNDLED_EDITLINE)

CMakeLists.txt:177 (MYSQL_CHECK_EDITLINE)

原因:没有安装Curses头文件。顺便提一句,Curses是用于在终端里显示GUI的。
解决:安装libncurses5-dev,在不同的发行版了,名字可能不相同。

#2 PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND

make[2]: *** No rule to make target ‘../mysqlxtest/PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND’, needed by ‘mysqlxtest/mysqlx_notice.pb.cc’. Stop.
CMakeFiles/Makefile2:234: recipe for target ‘mysqlxtest/CMakeFiles/mysqlxtest.dir/all’ failed
make[1]: *** [mysqlxtest/CMakeFiles/mysqlxtest.dir/all] Error 2

原因:为了偷懒,安装protobuf时,从源里安装的是libprotobuf-dev,而没有安装protobuf-c-compiler
解决:安装protobuf-c-compiler

参考文献