本篇内容主要讲解“Python如何安装mariadb对应的MySQLdb扩展”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Python如何安装mariadb对应的MySQLdb扩展”吧!
十余年的芒市网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。营销型网站建设的优势是能够根据用户设备显示端的尺寸不同,自动调整芒市建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“芒市网站设计”,“芒市网站推广”以来,每个客户项目都认真落实执行。debian下安装
比如网上的方案是:
apt-get install libmysql-dev apt-get install libmysqlclient-dev apt-get install python-dev pip install mysqlclient
这些命令一般情况下是没问题的,但是本机上安装的是maraidb,那就扯淡了
MariaDB [(none)]> select version(); +--------------------------+ | version() | +--------------------------+ | 10.1.38-MariaDB-0+deb9u1 | +--------------------------+
搜索apt的源发现没有相应的libmysql-dev 之类的,搜索如下:
ljf@ljf:/var/www/python$ sudo apt-cache search libmysql libglpk40 - linear programming kit with integer (MIP) support libcrypt-mysql-perl - Perl module to emulate the MySQL PASSWORD() function libmysql-diff-perl - module for comparing the table structure of two MySQL databases libreoffice-base-drivers - Database connectivity drivers for LibreOffice solr-common - Enterprise search server based on Lucene3 - common files libmariadbclient-dev-compat - MariaDB database development files (libmysqlclient compatibility) libmysql++-dev - MySQL C++ library bindings (development) libmysql++-doc - MySQL C++ library bindings (documentation and examples) libmysql++3v5 - MySQL C++ library bindings (runtime) libmysqlcppconn-dev - MySQL Connector for C++ (development files) libmysqlcppconn7v5 - MySQL Connector for C++ (library) libmysql-java - Java database (JDBC) driver for MySQL libmysql-cil-dev - MySQL database connector for CLI libmysql6.4-cil - MySQL database connector for CLI default-libmysqlclient-dev - MySQL database development files (metapackage) libmysql-ocaml - OCaml bindings for MySql (runtime package) libmysql-ocaml-dev - OCaml bindings for MySql (development package) node-mysql - MySQL client implementation for Node.js
搜索出来的源感觉不是那么对,但是有个源的名称叫:libmariadbclient-dev-compat ,那么会不会是要下载libmariadb的源文件呢,搜索下libmariadb对应的扩展看看:
ljf@ljf:/var/www/python$ sudo apt-cache search libmariadb libmariadbclient-dev - MariaDB database development files libmariadbclient-dev-compat - MariaDB database development files (libmysqlclient compatibility) libmariadbclient18 - MariaDB database client library libmariadbd-dev - MariaDB embedded database, development files libmariadbd18 - MariaDB embedded database, shared library libmariadb-dev - MariaDB Connector/C, development files libmariadb-dev-compat - MariaDB Connector/C, compatibility symlinks libmariadb2 - MariaDB Connector/C default-libmysqlclient-dev - MySQL database development files (metapackage)
果然libmariadb的源文件和推荐命令十分相似,安装试试:
apt-get install libmariadbd-dev apt-get install libmariadbdclient-dev apt-get install python-dev pip install mysqlclient
执行完毕之后,测试:
ljf@ljf:/var/www/python$ python Python 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import MySQLdb >>> exit()
到此,相信大家对“Python如何安装mariadb对应的MySQLdb扩展”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!