In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Any slightly more complex website can not do without data exchange. When developing with Django, you need to configure the database. When selecting mysql database, if you want django and mysql to "communicate" and exchange data smoothly, you need a bridge-MySQLdb. After upgrading the computer ubuntu system the night before last (from 14.04LTS version to 16.04LTS) Then the previous project on the computer reported an error after executing the python manage.py runserver command, and the error message was django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient.so.18: cannot open shared object file: No such file or directory.
Then Baidu looked for solutions, including looking for solutions on Stackoverflow. Most articles said that MySQLdb may not have been installed, and then I went to install MySQLdb, but the system reminder has been installed, and the reminder message is as follows: Requirement already satisfied (use-- upgrade to upgrade): MySQL-python==1.2.3 in / usr/local/lib/python2.7/dist-packages
This means that there is MySQL-python in the system, but why do you report an error? I thought about it for a long time, and then I thought of uninstalling and reinstalling, and then the problem was solved (, the artifact, in fact, I don't understand why, it may have something to do with the system, after upgrading the system, some of the previous things may not work).
I encountered a lot of problems when installing MySQLdb on the previous version of ubuntu 14.04LTS. I would like to make a summary here today. These are all the problems I usually encounter. I may encounter more in the future. I can slowly add that friends in need can refer to them (no corrections, but also hope to give advice).
MySQLdb installation
Installation is very simple, if your computer has pythoneer three artifacts virtualenv, fabric and pip (if you are a python developer, finally install, these three tools are indeed very powerful, online installation method, do not introduce here), install MySQLdb is very simple, a command can be solved.
Pip install MySQL-python
If you want to specify the version, you can do this.
Pip install MySQL-python==1.2.3
If the installation fails (as long as you make sure that pip is installed successfully and can be used), it may be a permission problem, so add sudo before pip at this time.
But do you think that's all right? This may be fine on windows, but not on ubuntu. It requires some dependency packages, and the installation command is as follows:
Sudo apt-get install mysql-client sudo apt-get install libmysqlclient-devsudo apt-get install python-dev
Then import MySQLdb, if you report correctly, the installation is successful.
two。 Frequently asked questions when performing python manage.py runserver
(1) error: mysql_config not found
Solution: install the mysqld-dev package, and the installation command has
(2) error: _ mysql.c:2810: error: expected declaration specifiers before 'init_mysql'
Solution: install python-dev
(3) error: ImportError: No module named setuptools
Solution: install setuptools
Sudo apt-get install python-setuptools
(4) error 1193, "Unknown system variable 'storage_engine'"
It may be related to the database configuration of django or the mysql configuration file.
Add a sentence to the database configuration:
'OPTIONS': {
'init_command': 'SET default_storage_engine=INNODB'
}
The problem can be solved.
After MySQL5.5, the default database storage engine is innod. I use version 5.7, and my previous configuration is
'OPTIONS': {
'init_command': 'SET storage_engine=MyISAM'
}
So it will report an error, so there are two ways to modify it, one is to change the django setting file, and the other is to change the mysql configuration file etc/mysql/my.cnf, adding a SET default_storage_engine=MyISAM, but no matter how you change it, the two should be consistent.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.