Error One:
The code is as follows |
Copy Code |
File "/usr/lib/pymodules/python2.6/mysqldb/__init__.py", line Bayi, in Connect Return Connection (*args, **kwargs) File "/usr/lib/pymodules/python2.6/mysqldb/connections.py", line 170, in __init__ Super (Connection, self). __init__ (*args, **KWARGS2) _mysql_exceptions. Operationalerror: (2003, "Can" T connect to the MySQL server on ' xxx.xxx.xxx.xxx ' (111) ") |
Workaround:
1, edit my.cnf, default is/etc/mydql/my.cnf, comment out bind-address = 127.0.0.1 or modify to 0.0.0.0;
The code is as follows |
Copy Code |
# Instead of skip-networking The default is now to listen only # localhost which are more compatible and are not less secure. # bind-address = 127.0.0.12, restart MySQL: Sudo/etc/init.d/mysql restart |
Error Two:
The code is as follows |
Copy Code |
File "/usr/lib/pymodules/python2.6/mysqldb/__init__.py", line Bayi, in Connect Return Connection (*args, **kwargs) File "/usr/lib/pymodules/python2.6/mysqldb/connections.py", line 170, in __init__ Super (Connection, self). __init__ (*args, **KWARGS2) _mysql_exceptions. Operationalerror: (1130, "Host ' xxx.xxx.xxx.xxx ' isn't allowed to connect to this MySQL server") |
Workaround:
The code is as follows |
Copy Code |
Mysql> GRANT all privileges in *.* to ' root ' @ '% ' identified under ' root ' with GRANT OPTION; This statement means: Allow all the root user and enter the root password of the host Log in to the MySQL Server. |
The username and password are replaced with the required, if the '% ' is replaced by the corresponding host name, then only the host can log in.
Error Three:
The code is as follows |
Copy Code |
(1040, ' Too many connections ') The reason is: ' Nonetype ' object has no attribute ' cursor ' web crawler to multiple threads, the connection database has the above error. |
Workaround One:
The code is as follows |
Copy Code |
Edit my.cnf, default is/etc/mydql/my.cnf, modify Max_connections value is 10000, the default is 100, the actual MySQL server allows the maximum number of connections 16384. |
Workaround Two:
Use a database connection pool.
Workaround Three:
Before the program structure to crawl to a data that produces an SQL statement that inserts a data, modify the program structure to put the process threads generated SQL statements into the queue, with a separate process to get out of SQL Insert database.