Linux python connection MySQL exception

Source: Internet
Author: User

The home computer uses the Linux operating system, the recently collected data needs to be stored to MySQL, originally uses the web.py the time to use the MySQL is all normal, results now directly uses the MYSQLDB to connect the database the exception:

/usr/lib/python2.7/dist-packages/pkg_resources.py:1031:userwarning:/home/huayuan/.python-eggs is writable by group /others and vulnerable to attack when used with Get_resource_filename. Consider a more secure location (set with. Set_extraction_path or the Python_egg_cache environment variable).
Warnings.warn (msg, userwarning)


Look at the prompt should be Linux system permissions problem, and on the XP computer verified that the connection to the MySQL Python code itself is not a problem, the code is as follows:

#coding =utf-8import mysqldbtry:conn = mysqldb.connect (host = ' 127.0.0.1 ', user = ' root ', passwd = ', db = ' sys ') c ur = conn.cursor () cur.execute ("INSERT into book (description) Select ' Test ' from dual where NOT exists (select 1 from b ook where id = 7) "Conn.commit () Cur.close () conn.close () except Mysqldb.error, E:print ' MySQL Error:%d%s ' % (E.arg[0], e.arg[1])


Initially it is easy to assume that the permissions are insufficient, follow the prompts in the Linux terminal will/home/huayuan/.python-eggs increase read and Write permissions:

chmod A+rw/home/huayuan/.python-eggs

The problem is still, and then after repeated search, finally found the answer, it is not to increase permissions, but to reduce some of the permissions, the final valid answer is as follows:

chmod g-wx, O-wx/home/huayuan/.python-eggs


This article is from the "Free Self" blog, please be sure to keep this source http://hhuayuan.blog.51cto.com/1630327/1574716

Linux python connection MySQL exception

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.