美文网首页
python链接数据库问题

python链接数据库问题

作者: 光光的杂货铺 | 来源:发表于2016-11-09 10:26 被阅读0次

    1.需要安装python支持mysql的库 pymysql
    pip install pymysql
    2.授权数据库允许哪些主机访问
    mysql> grant all on . to 'root'@'allow_host' identified by 'passwd';

    . db_name.tb_name即数据库名.表名
    allow_host:可以为ip地址,FQDN,或者使用%表示所有主机
    也可以使用192.168.%.%
    数据库中查询中文乱码解决办法:
    mysql>set names utf8;

    相关文章

      网友评论

          本文标题:python链接数据库问题

          本文链接:https://www.haomeiwen.com/subject/unbzuttx.html