{"id":874,"date":"2013-11-30T00:05:50","date_gmt":"2013-11-29T16:05:50","guid":{"rendered":"http:\/\/guoh.ai\/lifelog\/?p=874"},"modified":"2013-12-02T15:57:46","modified_gmt":"2013-12-02T07:57:46","slug":"hello-python-and-mysql-environment-setup","status":"publish","type":"post","link":"https:\/\/guoh.ai\/lifelog\/2013\/11\/hello-python-and-mysql-environment-setup\/","title":{"rendered":"Python\u8fde\u63a5MySQL\u6570\u636e\u5e93"},"content":{"rendered":"<p><strong>UPDATE: \u5176\u5b9e\u76ee\u524d\u6ca1\u6709\u7528\u5230\u591a\u5c11Python\u77e5\u8bc6\u6765\u5199\uff0c\u57fa\u672c\u90fd\u662f\u76f4\u63a5\u8c03\u7528\u7684\u5df2\u6709\u7684\u547d\u4ee4\u6765\u5b8c\u6210\u5907\u4efd\u548c\u90ae\u4ef6\u901a\u77e5\u529f\u80fd @@<\/strong><br \/>\n\u4e3a\u4e86\u5199\u4e2a\u7b80\u5355\u7684\u5907\u4efd\u7a0b\u5e8f\uff0c\u6211\u51b3\u5b9a\u4f7f\u7528Python\u6765\u5b9e\u73b0\uff0c\u51e0\u5e74\u524d\u6709\u770b\u8fc7\u70b9Python\uff0c\u4eca\u5929\u5c31\u6765\u8bd5\u8bd5\u770b\u3002\u901a\u5e38\u6211\u4eec\u8fde\u63a5\u6570\u636e\u5e93\u4f1a\u7528\u5230\u5bf9\u5e94\u7684\u8fde\u63a5API\uff0c\u6bd4\u5982Java\u7684JDBC(Java_Database_Connectivity\u200e)\uff0c\u9876\u591a\u4e2d\u95f4\u589e\u52a0\u4e2a\u8fde\u63a5\u6c60\u4e4b\u7c7b\u7684\uff0c\u56e0\u4e3a\u6211\u4eec\u8fd9\u91cc\u5f88\u7b80\u5355\uff0c\u6240\u4ee5\u53ea\u9700\u8981\u4e00\u4e2a\u7c7b\u4f3c\u7684API\uff0c\u6211\u4eec\u8fd9\u91cc\u7528MySQL-python\u6765\u5b8c\u6210\u3002\u5148\u5b89\u88c5\u8fd9\u4e2a\u4e1c\u897f\uff0c\u6211\u91c7\u75281.2.3\u7248\u672c\uff0c\u5f53\u7136\u6211\u8fd9\u91cc\u5bbf\u4e3b\u673a\u5668\u662fCentOS\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;guohai@Knight-on-the-Cloud installation]$ wget http:\/\/sourceforge.net\/projects\/mysql-python\/files\/mysql-python\/1.2.3\/MySQL-python-1.2.3.tar.gz\/download\r\n&#x5B;guohai@Knight-on-the-Cloud installation]$ tar xvf MySQL-python-1.2.3.tar.gz\r\n&#x5B;guohai@Knight-on-the-Cloud installation]$ cd MySQL-python-1.2.3\r\n<\/pre>\n<p>vim site.cfg<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n# The path to mysql_config.\r\n# Only use this if mysql_config is not on your PATH, or you have some weird\r\n# setup that requires it.\r\nmysql_config = \/usr\/bin\/mysql_config\r\n<\/pre>\n<p>\u6b63\u5982\u8fd9\u4e0a\u9762\u6240\u8bf4\uff0c\u4e4b\u524d\u6211\u5b89\u88c5MySQL\u6709\u6539\u52a8\u9ed8\u8ba4\u4f4d\u7f6e\uff0c\u6240\u4ee5\u8fd9\u91cc\u8981\u5355\u72ec\u6307\u5b9a\u4e0b\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;guohai@Knight-on-the-Cloud MySQL-python-1.2.3]$ python setup.py build\r\n<\/pre>\n<p>if errors(&#8220;no setuptools&#8221;) showing<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd ..\r\nwget https:\/\/pypi.python.org\/packages\/2.6\/s\/setuptools\/setuptools-0.6c10-py2.6.egg --no-check-certificate\r\nsh setuptools-0.6c10-py2.6.egg\r\n<\/pre>\n<p>\u7136\u540e<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd MySQL-python-1.2.3\r\n\r\n&#x5B;guohai@Knight-on-the-Cloud MySQL-python-1.2.3]$ python setup.py build\r\n<\/pre>\n<p>if errors(&#8220;Python.h: No such file or directory&#8221;) showing<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;root@Knight-on-the-Cloud installation]# yum -y install python-devel\r\n<\/pre>\n<p>\u7ee7\u7eed<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;guohai@Knight-on-the-Cloud MySQL-python-1.2.3]$ python setup.py build\r\nrunning build\r\nrunning build_py\r\ncopying MySQLdb\/release.py -&gt; build\/lib.linux-x86_64-2.6\/MySQLdb\r\nrunning build_ext\r\nbuilding &#039;_mysql&#039; extension\r\ngcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,3,&#039;final&#039;,0) -D__version__=1.2.3 -I\/usr\/include\/mysql -I\/usr\/include\/python2.6 -c _mysql.c -o build\/temp.linux-x86_64-2.6\/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV_LINUX -DUNIV_LINUX\r\n_mysql.c:36:23: error: my_config.h: No such file or directory\r\n_mysql.c:38:19: error: mysql.h: No such file or directory\r\n_mysql.c:39:26: error: mysqld_error.h: No such file or directory\r\n_mysql.c:40:20: error: errmsg.h: No such file or directory\r\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;root@Knight-on-the-Cloud include]# yum -y install mysql-devel\r\n\r\n&#x5B;root@Knight-on-the-Cloud mysql]# pwd\r\n\/usr\/include\/mysql\r\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;guohai@Knight-on-the-Cloud MySQL-python-1.2.3]$ python setup.py build\r\nrunning build\r\nrunning build_py\r\ncopying MySQLdb\/release.py -&gt; build\/lib.linux-x86_64-2.6\/MySQLdb\r\nrunning build_ext\r\nbuilding &#039;_mysql&#039; extension\r\ngcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,3,&#039;final&#039;,0) -D__version__=1.2.3 -I\/usr\/include\/mysql -I\/usr\/include\/python2.6 -c _mysql.c -o build\/temp.linux-x86_64-2.6\/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV_LINUX -DUNIV_LINUX\r\nIn file included from \/usr\/include\/mysql\/my_config.h:14,\r\n                 from _mysql.c:36:\r\n\/usr\/include\/mysql\/my_config_x86_64.h:1082:1: warning: &quot;HAVE_WCSCOLL&quot; redefined\r\nIn file included from \/usr\/include\/python2.6\/pyconfig.h:6,\r\n                 from \/usr\/include\/python2.6\/Python.h:8,\r\n                 from pymemcompat.h:10,\r\n                 from _mysql.c:29:\r\n\/usr\/include\/python2.6\/pyconfig-64.h:808:1: warning: this is the location of the previous definition\r\ngcc -pthread -shared build\/temp.linux-x86_64-2.6\/_mysql.o -L\/usr\/lib64\/mysql -L\/usr\/lib64 -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -lssl -lcrypto -lpython2.6 -o build\/lib.linux-x86_64-2.6\/_mysql.so\r\n<\/pre>\n<p>\u7f16\u8bd1\u597d\u4e86\u5c31\u5b89\u88c5<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;root@Knight-on-the-Cloud MySQL-python-1.2.3]# python setup.py install\r\nrunning install\r\nrunning bdist_egg\r\nrunning egg_info\r\nwriting MySQL_python.egg-info\/PKG-INFO\r\nwriting top-level names to MySQL_python.egg-info\/top_level.txt\r\nwriting dependency_links to MySQL_python.egg-info\/dependency_links.txt\r\nreading manifest file &#039;MySQL_python.egg-info\/SOURCES.txt&#039;\r\nreading manifest template &#039;MANIFEST.in&#039;\r\nwarning: no files found matching &#039;MANIFEST&#039;\r\nwarning: no files found matching &#039;ChangeLog&#039;\r\nwarning: no files found matching &#039;GPL&#039;\r\nwriting manifest file &#039;MySQL_python.egg-info\/SOURCES.txt&#039;\r\ninstalling library code to build\/bdist.linux-x86_64\/egg\r\nrunning install_lib\r\nrunning build_py\r\ncopying MySQLdb\/release.py -&gt; build\/lib.linux-x86_64-2.6\/MySQLdb\r\nrunning build_ext\r\ncreating build\/bdist.linux-x86_64\r\ncreating build\/bdist.linux-x86_64\/egg\r\ncopying build\/lib.linux-x86_64-2.6\/_mysql.so -&gt; build\/bdist.linux-x86_64\/egg\r\ncopying build\/lib.linux-x86_64-2.6\/_mysql_exceptions.py -&gt; build\/bdist.linux-x86_64\/egg\r\ncreating build\/bdist.linux-x86_64\/egg\/MySQLdb\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/__init__.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/cursors.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/connections.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/times.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/release.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\r\ncreating build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/constants\/REFRESH.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/constants\/CLIENT.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/constants\/FIELD_TYPE.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/constants\/FLAG.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/constants\/__init__.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/constants\/CR.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/constants\/ER.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\r\ncopying build\/lib.linux-x86_64-2.6\/MySQLdb\/converters.py -&gt; build\/bdist.linux-x86_64\/egg\/MySQLdb\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/_mysql_exceptions.py to _mysql_exceptions.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/__init__.py to __init__.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/cursors.py to cursors.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/connections.py to connections.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/times.py to times.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/release.py to release.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\/REFRESH.py to REFRESH.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\/CLIENT.py to CLIENT.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\/FIELD_TYPE.py to FIELD_TYPE.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\/FLAG.py to FLAG.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\/__init__.py to __init__.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\/CR.py to CR.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/constants\/ER.py to ER.pyc\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/MySQLdb\/converters.py to converters.pyc\r\ncreating stub loader for _mysql.so\r\nbyte-compiling build\/bdist.linux-x86_64\/egg\/_mysql.py to _mysql.pyc\r\ncreating build\/bdist.linux-x86_64\/egg\/EGG-INFO\r\ncopying MySQL_python.egg-info\/PKG-INFO -&gt; build\/bdist.linux-x86_64\/egg\/EGG-INFO\r\ncopying MySQL_python.egg-info\/SOURCES.txt -&gt; build\/bdist.linux-x86_64\/egg\/EGG-INFO\r\ncopying MySQL_python.egg-info\/dependency_links.txt -&gt; build\/bdist.linux-x86_64\/egg\/EGG-INFO\r\ncopying MySQL_python.egg-info\/top_level.txt -&gt; build\/bdist.linux-x86_64\/egg\/EGG-INFO\r\nwriting build\/bdist.linux-x86_64\/egg\/EGG-INFO\/native_libs.txt\r\nzip_safe flag not set; analyzing archive contents...\r\ncreating dist\r\ncreating &#039;dist\/MySQL_python-1.2.3-py2.6-linux-x86_64.egg&#039; and adding &#039;build\/bdist.linux-x86_64\/egg&#039; to it\r\nremoving &#039;build\/bdist.linux-x86_64\/egg&#039; (and everything under it)\r\nProcessing MySQL_python-1.2.3-py2.6-linux-x86_64.egg\r\nCopying MySQL_python-1.2.3-py2.6-linux-x86_64.egg to \/usr\/lib64\/python2.6\/site-packages\r\nAdding MySQL-python 1.2.3 to easy-install.pth file\r\n\r\nInstalled \/usr\/lib64\/python2.6\/site-packages\/MySQL_python-1.2.3-py2.6-linux-x86_64.egg\r\nProcessing dependencies for MySQL-python==1.2.3\r\nFinished processing dependencies for MySQL-python==1.2.3\r\n<\/pre>\n<p>\u63a5\u7740\u518d\u6765\u8bd5\u4e0b<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;guohai@Knight-on-the-Cloud MySQL-python-1.2.3]$ python\r\nPython 2.6.6 (r266:84292, Jul 10 2013, 22:48:45) \r\n&#x5B;GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2\r\nType &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.\r\n&gt;&gt;&gt; import MySQLdb\r\n\/usr\/lib64\/python2.6\/site-packages\/MySQL_python-1.2.3-py2.6-linux-x86_64.egg\/_mysql.py:3: UserWarning: Module _mysql was already imported from \/usr\/lib64\/python2.6\/site-packages\/MySQL_python-1.2.3-py2.6-linux-x86_64.egg\/_mysql.pyc, but \/home\/guohai\/apps\/installation\/MySQL-python-1.2.3 is being added to sys.path\r\n<\/pre>\n<p>\u4e0a\u9762\u8fd9\u4e9bUserWarning\u662f\u8bf4MySQL\u6a21\u5757\u5df2\u7ecf\u5f15\u5165\u4e86\uff0c\u4f46\u662f\u4f60\u5728\u7684\u76ee\u5f55\u53c8\u88ab\u52a0\u5165\u5230sys.path\uff0c\u4e5f\u5c31\u662f\u91cd\u590d\u5f15\u5165\u3002\u8fd9\u4e2a\u65f6\u5019\u4f60\u53ea\u8981\u8df3\u51fa\u6211\u4eec\u521a\u521a\u7f16\u8bd1\u6a21\u5757\u7684\u76ee\u5f55\u5c31\u597d\u4e86\u3002<br \/>\n\u4e00\u5207\u90fd\u6b63\u5e38\u4e4b\u540e\u6211\u4eec\u6765\u5199\u4e2a\u7b80\u5355\u7684\u7a0b\u5e8f\u8bd5\u8bd5\u770b\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;guohai@Knight-on-the-Cloud npc]$ python\r\nPython 2.6.6 (r266:84292, Jul 10 2013, 22:48:45) \r\n&#x5B;GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2\r\nType &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.\r\n&gt;&gt;&gt; import MySQLdb\r\n\r\n&gt;&gt;&gt; help(MySQLdb) \/\/ \u4e0d\u61c2\u7684\u8bdd\u5c31\u53ef\u4ee5\u8fd9\u6837\u67e5\u8be2\r\n\r\n&gt;&gt;&gt; conn = MySQLdb.connect(&#039;localhost&#039;, &#039;wp_user&#039;, &#039;wp_passwd&#039;, &#039;wp_db&#039;)\r\n&gt;&gt;&gt; cur = conn.cursor()\r\n&gt;&gt;&gt; cur.execute(&#039;select user_login, user_registered from wp_users&#039;)\r\n1L\r\n&gt;&gt;&gt; rst = cur.fetchall()\r\n&gt;&gt;&gt; print rst\r\n((&#039;admin&#039;, datetime.datetime(2011, 3, 19, 0, 8, 9)),)\r\n&gt;&gt;&gt; cur.close()\r\n&gt;&gt;&gt; conn.close()\r\n<\/pre>\n<p>\u4e0e\u6211\u4eec\u901a\u8fc7<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;guohai@Knight-on-the-Cloud npc]# mysql -h localhost -u wp_user -p\r\n<\/pre>\n<p>\u67e5\u8be2\u51fa\u6765\u7684\u4e00\u6837<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmysql&gt; select * from wp_users \\G\r\n*************************** 1. row ***************************\r\n                 ID: 1\r\n         user_login: admin\r\n          user_pass: #CLASSIFIED#\r\n      user_nicename: #CLASSIFIED#\r\n         user_email: #CLASSIFIED#\r\n           user_url: #CLASSIFIED#\r\n    user_registered: 2011-03-19 00:08:09\r\nuser_activation_key: #CLASSIFIED#\r\n        user_status: #CLASSIFIED#\r\n       display_name: #CLASSIFIED#\r\n1 row in set (0.00 sec)\r\n<\/pre>\n<p>\u4e5f\u5c31\u662f\u8bf4\u6211\u4eec\u7b80\u5355\u7684\u8fde\u63a5\u6570\u636e\u5e93\u6210\u529f\u4e86\uff0c\u5230\u6b64\u57fa\u7840\u73af\u5883\u7b97\u662f\u642d\u5efa\u597d\u4e86\u3002<\/p>\n<p>\u53e6\u5916\u7b80\u5355\u5199\u4e86\u4e2a<a href=\"https:\/\/github.com\/guohai\/my-conf\/blob\/master\/wp_backup_npc.py\" target=\"_blank\">\u5907\u4efd\u7a0b\u5e8f<\/a>(https:\/\/github.com\/guohai\/my-conf\/blob\/master\/wp_backup_npc.py)\uff0c\u5f85\u5b8c\u5584\u3002\u3002\u3002<\/p>\n<p>\u7136\u540e\u7f16\u5199\u4e00\u4e2acrontab\u5c31\u53ef\u4ee5\u8ba9\u5b83\u5b9a\u65f6\u6267\u884c(\u4e0d\u4f1acrontab\u7684\u8bf7\u53c2\u89c1http:\/\/linux.vbird.org\/linux_basic\/redhat6.1\/linux_11cron.php)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n9 16 * * 0 cd \/home\/guohai\/apps\/npc\/ &amp;&amp; python wp_backup_npc.py &amp;&gt; \/dev\/null\r\n<\/pre>\n<p>\u5c31\u662f\u5728\u6bcf\u5468\u65e5\u768416\u70b99\u5206\u4f1a\u8fd0\u884c\u4e00\u6b21\u540e\u9762\u7684\u547d\u4ee4(\u8df3\u8f6c\u5230npc\u6587\u4ef6\u5939\uff0c\u6267\u884c\u8fd9\u4e2apython\u547d\u4ee4\uff0c\u5982\u679c\u6709\u4e00\u4e9b\u4fe1\u606f\u8f93\u51fa\u7684\u8bdd\u5c31\u628a\u4fe1\u606f\u91cd\u5b9a\u5411\u5230\/dev\/null\uff0c\u5982\u679c\u6709\u4fe1\u606f\u8f93\u51fa\u800c\u4e0d\u91cd\u5b9a\u5411\u8fd9\u4e9b\u4fe1\u606f\u7684\u8bdd\uff0ccrontab\u5c31\u4f1a\u8ba4\u4e3a\u8fd9\u4e2a\u547d\u4ee4\u662f\u6267\u884c\u5931\u8d25\u7684\uff0c\u6240\u4ee5\u5c31\u4f1a\u7ed9\u4f60\u7684\u90ae\u7bb1\u53d1\u5c01\u63d0\u9192\u90ae\u4ef6\uff0c\u65f6\u95f4\u4e45\u4e86\u4f60\u7684\/var\/spool\/mail\/\u8d26\u6237\u4e0b\u5c31\u4f1a\u6709\u5f88\u591a\u90ae\u4ef6\uff0c\u6240\u4ee5\u8fd9\u91cc\u6211\u628a\u4e00\u5207\u8f93\u51fa\u4fe1\u606f\u90fd\u91cd\u5b9a\u5411\u5230\/dev\/null\u4e86)\u3002<\/p>\n<p>\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u9605\u8bfb\u7b80\u5355\u7684\u4ecb\u7ecd\u4e86\u89e3crontab\u811a\u672c\u5982\u4f55\u7f16\u5199\uff0c\u5982\u4e0b\uff1a<\/p>\n<blockquote><p>\n# Edit this file to introduce tasks to be run by cron.<br \/>\n#<br \/>\n# Each task to run has to be defined through a single line<br \/>\n# indicating with different fields when the task will be run<br \/>\n# and what command to run for the task<br \/>\n#<br \/>\n# To define the time you can provide concrete values for<br \/>\n# minute (m), hour (h), day of month (dom), month (mon),<br \/>\n# and day of week (dow) or use &#8216;*&#8217; in these fields (for &#8216;any&#8217;).#<br \/>\n# Notice that tasks will be started based on the cron&#8217;s system<br \/>\n# daemon&#8217;s notion of time and timezones.<br \/>\n#<br \/>\n# Output of the crontab jobs (including errors) is sent through<br \/>\n# email to the user the crontab file belongs to (unless redirected).<br \/>\n#<br \/>\n# For example, you can run a backup of all your user accounts<br \/>\n# at 5 a.m every week with:<br \/>\n# 0 5 * * 1 tar -zcf \/var\/backups\/home.tgz \/home\/<br \/>\n#<br \/>\n# For more information see the manual pages of crontab(5) and cron(8)<br \/>\n#<br \/>\n# m h  dom mon dow   command\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>UPDATE: \u5176\u5b9e\u76ee\u524d\u6ca1\u6709\u7528\u5230\u591a\u5c11Python\u77e5\u8bc6\u6765\u5199\uff0c\u57fa\u672c\u90fd\u662f\u76f4\u63a5\u8c03\u7528\u7684\u5df2\u6709\u7684\u547d\u4ee4\u6765\u5b8c\u6210\u5907\u4efd\u548c\u90ae\u4ef6\u901a\u77e5\u529f\u80fd @@ \u4e3a\u4e86\u5199\u4e2a\u7b80\u5355\u7684\u5907\u4efd\u7a0b\u5e8f\uff0c\u6211\u51b3\u5b9a\u4f7f\u7528Python\u6765\u5b9e\u73b0\uff0c\u51e0\u5e74\u524d\u6709\u770b\u8fc7\u70b9Python\uff0c\u4eca\u5929\u5c31\u6765\u8bd5\u8bd5\u770b\u3002\u901a\u5e38\u6211\u4eec\u8fde\u63a5\u6570\u636e\u5e93\u4f1a\u7528\u5230\u5bf9\u5e94\u7684\u8fde\u63a5API\uff0c\u6bd4\u5982Java\u7684JDBC(Java_Database_Connectivity\u200e)\uff0c\u9876\u591a\u4e2d\u95f4\u589e\u52a0\u4e2a\u8fde\u63a5\u6c60\u4e4b\u7c7b\u7684\uff0c\u56e0\u4e3a\u6211\u4eec\u8fd9\u91cc\u5f88\u7b80\u5355\uff0c\u6240\u4ee5\u53ea\u9700\u8981\u4e00\u4e2a\u7c7b\u4f3c\u7684API\uff0c\u6211\u4eec\u8fd9\u91cc\u7528MySQL-python\u6765\u5b8c\u6210\u3002\u5148\u5b89\u88c5\u8fd9\u4e2a\u4e1c\u897f\uff0c\u6211\u91c7\u75281.2.3\u7248\u672c\uff0c\u5f53\u7136\u6211\u8fd9\u91cc\u5bbf\u4e3b\u673a\u5668\u662fCentOS\u3002 &#x5B;guohai@Knight-on-the-Cloud installation]$ wget http:\/\/sourceforge.net\/projects\/mysql-python\/files\/mysql-python\/1.2.3\/MySQL-python-1.2.3.tar.gz\/download &#x5B;guohai@Knight-on-the-Cloud installation]$ tar xvf MySQL-python-1.2.3.tar.gz &#x5B;guohai@Knight-on-the-Cloud installation]$ cd MySQL-python-1.2.3 vim site.cfg # The path to mysql_config. # Only use this if mysql_config is not on your PATH, or you have some weird # setup that requires it. mysql_config = \/usr\/bin\/mysql_config \u6b63\u5982\u8fd9\u4e0a\u9762\u6240\u8bf4\uff0c\u4e4b\u524d\u6211\u5b89\u88c5MySQL\u6709\u6539\u52a8\u9ed8\u8ba4\u4f4d\u7f6e\uff0c\u6240\u4ee5\u8fd9\u91cc\u8981\u5355\u72ec\u6307\u5b9a\u4e0b\u3002 &#x5B;guohai@Knight-on-the-Cloud MySQL-python-1.2.3]$ python setup.py build if &hellip; <a href=\"https:\/\/guoh.ai\/lifelog\/2013\/11\/hello-python-and-mysql-environment-setup\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Python\u8fde\u63a5MySQL\u6570\u636e\u5e93<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gfmr_meta_descriptions":[],"_gfmr_multilingual_taxonomy_terms":[],"footnotes":""},"categories":[1],"tags":[24],"class_list":["post-874","post","type-post","status-publish","format-standard","hentry","category-misc","tag-tool"],"_links":{"self":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/comments?post=874"}],"version-history":[{"count":6,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/874\/revisions"}],"predecessor-version":[{"id":877,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/874\/revisions\/877"}],"wp:attachment":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/media?parent=874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/categories?post=874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/tags?post=874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}