「MySQL Workbench」

  CREATED BY JENKINSBOT

版本 6.3.9

配置、构建、安装

从Linux发行版的源中直接安装

#!/bin/sh

# Ubuntu 16.04 TLS
# mysql-workbench:主程序。
# mysql-workbench-data:相关的数据、SQL、脚本文件。
apt-get install mysql-workbench mysql-workbench-data

如果发行版的源里没有的话,可以直接到官网上下载已经打包好的安装包。

老样子,依旧是从源码开始安装。老规矩,看INSTALL文件。

下载、解压、进入源码目录

#!/bin/sh

wget https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-workbench-community-6.3.9-src.tar.gz
tar -xf mysql-workbench-community-6.3.9-src.tar.gz
cd mysql-workbench-community-6.3.9-src

安装依赖

#!/bin/sh

# - 移除 iodbc
apt-get remove iodbc


# - 安装依赖
apt-get install build-essential cmake cmake-data autoconf automake pkg-config libtool libzip-dev libxml2-dev \
                           libsigc++-2.0-dev libglade2-dev libgtkmm-2.4-dev libglu1-mesa-dev libgl1-mesa-glx \
                           mesa-common-dev libmysqlclient-dev libmysqlcppconn-dev uuid-dev libpixman-1-dev libpcre3-dev \
                           libgnome2-dev libgnome-keyring-dev libgtk2.0-dev libpango1.0-dev libcairo2-dev python-dev \
                           libboost-dev libctemplate-dev mysql-client python-pysqlite2 libsqlite3-dev \
                           swig libvsqlitepp-dev libgdal-dev libproj0

开始构建、编译、安装

#!/bin/sh

mkdir wb-build
cd wb-build
cmake [-DCMAKE_INSTALL_PREFIX=/usr] ..

# ***注意:这里我们没使用make的 -j 选项,之前使用了-j选项,编译到48%时出错了。
make && make install

# - 手动指定安装路径。
make install DESTDIR=.

#
# Note about swig:
# - You will need swig 1.3 to build WB
#
# Note about antlr:
# - Antlr 3.4 is needed, but the current release has many bugs. You will need it patched with https://github.com/antlr/antlr3/pull/43 if you don't want to use the bundled version.
#   Then you'll need to
#
#       export ANTLR_JAR_PATH=<path_to_your_antlr_complete_file>
#
# Note about iodbc:
#  - instead of iodbc you can use unixodbc, to do that you need to install unixodbc and add -DUSE_UNIXODBC=True to cmake
#
# Note about gdal:
#  - Ubuntu Packages require unixodbc, so if you're using it, there won't be any problem. If you want to use iodbc, you'll need to build it from source.
# ......

Error List

以下的错误我们要说明一下,之所以出现这么多的错误是因为没有按照INSTALL文件指引操作,如果按照INSTALL文件描述的进行操作,不会出现这么多问题。
之所以没有没有按照INSTALL文件指引操作,是因为系统环境比较特殊一些。

#1 No package ‘gtk+-3.0’ found

— Checking for module ‘gtk+-3.0’
No package ‘gtk+-3.0’ found

解决:缺什么补什么,安装GTK3及GTK3大的开发文件(development files)。

#2 No package ‘gtkmm-3.0’ found

— Checking for module ‘gtkmm-3.0’
— No package ‘gtkmm-3.0’ found

解决:安装gtkmm,从源码编译也好,从源里安装也好。
Gtkmm为GTK+ 3提供了C++接口。
Homepage: http://www.gtkmm.org/en/
Download: ftp://ftp.gnome.org/pub/gnome/sources/gtkmm/3.22/gtkmm-3.22.0.tar.xz

#3 Unable to detect MySQLCppConn version

file STRINGS file
“/mnt/uui/packages/mysql-workbench-community-6.3.9-src/MySQLCppConn_INCLUDE_DIR-NOTFOUND/cppconn/version_info.h”
cannot be read.
Call Stack (most recent call first):
CMakeLists.txt:134 (find_package)

ERROR Unable to detect MySQLCppConn version
CMake Error at build/cmake/Modules/FindVSqlite.cmake:46 (get_filename_component):
get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
CMakeLists.txt:135 (find_package)

原因:缺少mysql-connector-c++。
解决:从源码编译也好,从源里安装也好。
Homepage: https://dev.mysql.com/downloads/connector/cpp/
老规矩还是看你INSTALL文件。

#4 Could NOT find VSQLITE

CMake Error at build/cmake/Modules/FindVSqlite.cmake:46 (get_filename_component):
get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
CMakeLists.txt:135 (find_package)

— Could NOT find VSQLITE (missing: VSQLITE_LIBRARY VSQLITE_INCLUDE_DIR)
VSQLITE INCLUDE DIR:
VSQLITE LIB DIR:
CMake Error at /usr/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find GDAL (missing: GDAL_LIBRARY GDAL_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.6/Modules/FindGDAL.cmake:116 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:136 (find_package)

原因:这个也很明显是缺少 vsqlite,vsqlite是为C++的SQLite3封装。
Homepage: https://github.com/vinzenz/vsqlite– ,后面的这两条杠也是网址的一部分。
解决:从源码编译也好,从源里安装也好。

#5 Could NOT find GDAL

CMake Error at /usr/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find GDAL (missing: GDAL_LIBRARY GDAL_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.6/Modules/FindGDAL.cmake:116 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:136 (find_package)

原因:很明显是缺少GDAL库。地理空间数据抽象库(Geospatial Data Abstraction Library)。
具体的这个库是做什么的我们没有深究过,我们猜测应该是和MySQL中的空间数据(Spatial Data)有关系。https://dev.mysql.com/doc/refman/5.7/en/spatial-extensions.html
解决:Homepage: http://www.gdal.org/
这是我们安装过的最难安装的库。

#6 No package ‘libzip’ found

— Checking for module ‘libzip’
No package ‘libzip’ found
CMake Error at /usr/share/cmake-3.6/Modules/FindPkgConfig.cmake:424 (message):
A required package was not found

原因:因为没有安装libzip,安装一下就完了。
解决:安装libzip的开发库

#7 antlr-3.4-complete.jar file could not be found

[mysql] Generating parser files…
Selected MySQL parser
The antlr-3.4-complete.jar file could not be found.
Please make sure that linux-res is in /mnt/uui/packages or add the ANTLR_JAR_PATH enviroment variable with the path to the file.
You’ll also need Java Runtime Enviroment installed, so the parser files can be regenerated.
CMake Error at library/parsers/grammars/CMakeLists.txt:9 (message):
[mysql] Generating parsers files failed with result=’1′

原因:antlr-3.4-complete.jar,偏偏少这么个东西。
解决:Download: http://www.antlr3.org/download/
同时要添加环境变量ANTLR_JAR_PATH:export ANTLR_JAR_PATH=/usr/share/java/antlr-3.4-complete.jar

#8 dal/ogrsf_frmts.h: No such file or directory

In file included from /mnt/uui/packages/mysql-workbench-community-6.3.9-src/backend/wbpublic/grt/spatial_handler.cpp:20:0:
/mnt/uui/packages/mysql-workbench-community-6.3.9-src/backend/wbpublic/grt/spatial_handler.h:23:30: fatal error: gdal/ogrsf_frmts.h: No such file or directory
#include <gdal/ogrsf_frmts.h>

^

compilation terminated.

原因:如果是从源中安装的gdal库,那是不会出现这个问题的;如果是你自己编译的gdal那就会存在这个问题。
源中的gdal库的头文件位于/usr/include/gdal文件夹下,而你自己编译的gdal库的头文件都位于/usr/include下(如果–prefix=/usr的话)。与此同时,mysql-workbench编译时,它到gdal下搜索ogrsf_frmts.h文件。
解决:编译gdal时,加上参数–includedir=/usr/include/gdal

#9 error while loading shared libraries: libmysqlcppconn.so.7

/opt/mysql-workbench/bin/mysql-workbench-bin: error while loading shared libraries: libmysqlcppconn.so.7: cannot ……

原因:没有找到libmysqlcppconn.so.7文件,这个库已经安装了,只是因为安装在lib64下,而lib64没有在库搜索路径中。
解决:在/etc/ld.so.conf.d下增加lib64.conf文件,文件的内容如下:

/usr/local/lib64

#10 error while loading shared libraries: libmysqlclient.so.20

/opt/mysql-workbench/bin/mysql-workbench-bin: error while loading shared libraries: libmysqlclient.so.20: cannot ……

原因:同#9是类似的。我们的MySQL使用的是二进制包,位于/usr/local/mysql,所以libmysqlclient.so.20没有在库搜索路径中。
解决:在/etc/ld.so.conf.d下增加mysql.conf文件,文件的内容如下:

/usr/local/mysql/lib

#11 Workbench can’t find libproj.so, some

Workbench can’t find libproj.so, some options may be unavailable.
Ready.
启动Workbench时的警告。

原因:因为没有安装libproj库。
解决:安装libproj库,到Github下载源码,或者去proj的主页

参考文献

MySQL Workbench
Homepage: https://www.mysql.com/products/workbench/
Doc: https://dev.mysql.com/doc/workbench/en/
ChangeLog: https://dev.mysql.com/doc/relnotes/workbench/en/
Forums: https://forums.mysql.com/list.php?152
Download: https://dev.mysql.com/downloads/workbench/