MariaDB

windows10 下安装 python 连接器

pip install mariadb

ubuntu 下安装 python 连接器

安装 python 驱动:https://mariadb.com/docs/connect/programming-languages/python/install/

1. 安装 c 连接器
参考:

wget https://dlm.mariadb.com/2453974/Connectors/c/connector-c-3.3.2/mariadb-connector-c-3.3.2-ubuntu-focal-amd64.tar.gz
tar zxvf mariadb-connector-c-3.3.2-ubuntu-focal-amd64.tar.gz
cd mariadb-connector-c-3.3.2-ubuntu-focal-amd64/
# mv -f 强制
sudo mv -f bin/mariadb_config /usr/bin/
# 获取编译信息
ht 2011-2020 MariaDB Corporation AB
Get compiler flags for using the MariaDB Connector/C.
Usage: mariadb_config [OPTIONS]
Compiler: GNU 9.3.0
  --cflags        [-I/usr/include/mariadb -I/usr/include/mariadb/mysql]
  --include       [-I/usr/include/mariadb -I/usr/include/mariadb/mysql]
  --libs          [-L/usr/lib/mariadb/ -lmariadb]
  --libs_r        [-L/usr/lib/mariadb/ -lmariadb]
  --libs_sys      [-ldl -lm -lpthread -lssl -lcrypto]
  --version       [10.8.4]
  --cc_version    [3.3.2]
  --socket        [/tmp/mysql.sock]
  --port          [3306]
  --plugindir     [/usr/lib/mariadb/plugin]
  --tlsinfo       [OpenSSL 1.1.1f]
  --variable=VAR  VAR is one of:
      pkgincludedir  [/usr/include/mariadb]
      pkglibdir      [/usr/lib/mariadb]
      pkgplugindir   [/usr/lib/mariadb/plugin]

# 移动文件
sudo mv -f include/mariadb/ /usr/include/mariadb/
sudo mv -f lib/mariadb /usr/lib/mariadb

2. 安装 python 连接器:pip install mariadb

python 脚本调用

参考:https://mariadb.com/resources/blog/how-to-connect-python-programs-to-mariadb/

评论(没有评论)