• 幕客老师召集小伙伴
  • 运维高手36项修炼
  • python自动化运维项目实战
  • nginx从入门到实战
  • 阿里云与Centos7实战

安装MySQL utf8mb4字符集

背景:在一个python的工程应用的时候,由于图片表情需要存储到msyql中,为了避免手动转译处理,需要安装 MySQL utf8mb4 

安装:

MySQL utf8mb4 需要Mysql5.5的版本支持,而目前我的服务端数据库为5.5,客户端为:5.19,所以在指定完数据配置后会出现连接报错。

处理的步骤如下:

在mysql的官方下载包

MySQL-client-5.5.44-1.rhel5.x86_64.rpm

MySQL-shared-5.5.44-1.rhel5.x86_64.rpm

1、如何确定python连接就是使用的mysql的哪个库文件呢?

#locate _mysql.so  //mysqldb模块会使用到这个模块,通过分析connection.py文件。

/usr/lib64/python2.6/site-packages/_mysql.so

#readelf -d /usr/lib64/python2.6/site-packages/_mysql.so //查看此模块使用到哪些系统模块


Dynamic section at offset 0x97e0 contains 29 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libmysqlclient_r.so.16] 
0x0000000000000001 (NEEDED) Shared library: [libz.so.1]
0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
0x0000000000000001 (NEEDED) Shared library: [libcrypt.so.1]
0x0000000000000001 (NEEDED) Shared library: [libnsl.so.1]
0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
0x0000000000000001 (NEEDED) Shared library: [libssl.so.10]
0x0000000000000001 (NEEDED) Shared library: [libcrypto.so.10]
0x0000000000000001 (NEEDED) Shared library: [libpython2.6.so.1.0]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000c (INIT) 0x3860

 

libmysqlclient_r.so.16 为系统模块

2、如何确定libmysqlclient_r.so.16 为系统模块?

$ ldconfig -p|grep mysql
libmysqlclient_r.so.16 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient_r.so.16
libmysqlclient_r.so (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient_r.so
libmysqlclient.so.18 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so.18

 这个时候我们需要查找到哪个rpm包使用/usr/lib64/mysql/libmysqlclient_r.so.16

3、如何确定呢?

rpm -qlp ./MySQL-shared-5.5.44-1.rhel5.x86_64.rpm
/usr/lib64/libmysqlclient.so
/usr/lib64/libmysqlclient.so.18
/usr/lib64/libmysqlclient.so.18.0.0
/usr/lib64/libmysqlclient_r.so
/usr/lib64/libmysqlclient_r.so.18
/usr/lib64/libmysqlclient_r.so.18.0.0

ln -s /usr/lib64/libmysqlclient_r.so.18.0.0 /usr/lib64/mysql/libmysqlclient_r.so.16

安装MySQL utf8mb4字符集

Pingbacks已打开。

引用地址

暂无评论

发表评论