This article is based on http://www.cnblogs.com/fnng/p/3565912.html this blog post, learning to use the MYSQLDB process encountered the following problems.
1. Install mysqldb when running sudo python setup.py install error environmenterror:mysql_config not found
When you install Mysql-python, it appears:
SH: Mysql_config:not foundtraceback (most recent call Last): File"setup.py", line the,inch<module>metadata, Options=get_config () File"/home/zhxia/apps/source/mysql-python-1.2.3/setup_posix.py", line +,inchGet_config Libs= Mysql_config ("Libs_r") File"/home/zhxia/apps/source/mysql-python-1.2.3/setup_posix.py", line -,inchMysql_config raise EnvironmentError ("%s not found"%(Mysql_config.path,)) Environmenterror:mysql_config not found
The reason is that there is no installation: Libmysqlclient-dev
sudo Install Libmysqlclient-dev
It's done here on your own computer. The text also has the following steps, if you still cannot install can try.
Find the path to the Mysql_config file
sudo UpdateDB Locate Mysql_config
Mysql_config is located at:/usr/bin/mysql_config
Under the Mysql-python source package, locate the: setup_posix.py file, and then locate the Mysql_config.path in the file to change its value to:/usr/bin/mysql_config, and then sudo python setup.py Install, it's OK.
Reference: http://www.cnblogs.com/xiazh/archive/2012/12/12/2814289.html
2.import mysqldb userwarning Error
The reason is that the install MYSQLDB module has been placed in the Python site-pachages directory, but the same module exists in the current directory, so the import may be repeated. Just switch to a different directory to run it.
Reference: http://blog.csdn.net/jiang1013nan/article/details/6270791
3. Remote connection Error Error 1130:host ' 115.1XX. X.3 ' isn't allowed to connect to this MySQL server
1. Change the table method. It may be that your account is not allowed to log on remotely, only on localhost. This time, as long as the computer on the localhost, log in to MySQL, change the "MySQL" Database in the "User" table "host", from "localhost" to "%"
use MySQL; Update User Set = ' % ' where User = ' Root ';
2. Authorization law. For example, if you want to myuser use MyPassword to connect to a MySQL server from any host.
GRANT All Privileges on *. * to ' MyUser '@ '%' by'mypassword' withGRANTOPTION;
If you want to allow users to connect to the MySQL server from a host myuser IP 192.168.1.3 and use MyPassword as the password
grant all privileges on * . * to " myuser " @" 192.168.1.3 " identified by & nbsp; < Br> " MyPassword " with grant option ;
I succeeded in using the first method.
Reference: http://blog.csdn.net/july_2/article/details/41896295
4.ERROR 2003 (HY000): Can ' t connect to MySQL server on ' 10.16.xxx.xxx ' (111)
bind_address=127.0.0.1 may be used (or other IP, of course)
[mysqld] bind_address = 127.0. 0.1
By reviewing the my.cnf file, comment out this sentence and restart the MySQL service.
There may be other issues, see references: http://blog.csdn.net/qustdjx/article/details/26937325/
5. How do i restart the MySQL service after I have modified the my.cnf?
Stop MySQL:
Mode one: Sudo/etc/init.d/mysql stop
Way two: sudo stop MySQL
Mode three: sudo service MySQL stop (pro-test feasible)
To restart MySQL:
Way One: sudo/etc/init.d/mysql restart
Way two: sudo restart MySQL
Way three: sudo service MySQL restart
Reference: http://www.2cto.com/database/201305/207791.html
Common problems and solutions for using MYSQLDB remote connection database in Ubuntu under Python