由于社区中MYSHELL SHELL版本是2.28,我特意安装了一台ORALCE LINUX 8虚拟机。
cat /etc/redhat-release
Red Hat Enterprise Linux release 8.9 (Ootpa)
ldd --version
ldd (GNU libc) 2.28
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
在使用社区的MYSQL SHELL时,
./mysqlsh
Python path configuration:
PYTHONHOME = '/usr/bin/python3'
PYTHONPATH = (not set)
program name = '/root/greatsql-shell-8.0.32-25-glibc2.28-x86_64/bin/mysqlsh'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/root/greatsql-shell-8.0.32-25-glibc2.28-x86_64/bin/mysqlsh'
sys.base_prefix = '/usr/bin/python3'
sys.base_exec_prefix = '/usr/bin/python3'
sys.executable = '/root/greatsql-shell-8.0.32-25-glibc2.28-x86_64/bin/mysqlsh'
sys.prefix = '/usr/bin/python3'
sys.exec_prefix = '/usr/bin/python3'
sys.path = [
'/usr/bin/python3/lib64/python38.zip',
'/usr/bin/python3/lib64/python3.8',
'/usr/bin/python3/lib64/python3.8/lib-dynload',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f78e3b8ef80 (most recent call first):
从上面的报错看,是python有问题。我安装的python3
在Greatsql社区发帖子咨询,叶金荣老师很快就回复了解决办法。作为开源社区,技术人员回复速度如此之快,确实少见。
解决方法如下:
# 先安装几个必要的依赖包
$ dnf install -y libssh python38 python38-libs python38-pyyaml
$ pip3.8 install --user certifi pyclamd
# 测试使用
$ /usr/local/greatsql-shell-8.0.32-25-centos-glibc2.28-x86_64/bin/mysqlsh
MySQL Shell 8.0.32
...
Type '\help' or '\?' for help; '\quit' to exit.
MySQL JS > \q
Bye!
按照上面的方面处理,果然解决问题了。
./mysqlsh
MySQL Shell 8.0.32
Copyright (c) 2016, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit.
WARNING: Found errors loading plugins, for more details look at the log at: /root/.mysqlsh/mysqlsh.log
MySQL JS > \py\
Unknown command: '\py\'
MySQL JS > \py