Abstract:Experience sharing about MySQL and Django version matching knowledge.
(env) E:\PythonPro\PyDjangoProDemo011\xuanyuaniotpro>python manage.py migrate
The error code prompt is as follows:
raise errorclass(errno, errval) django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1") During handling of the above exception, another exception occurred:
According to the prompts, the causes of the error were analyzed
Django2.1 no longer supports MySQL 5.5, and must be mysql5.6 or above
Check MySQL version and Django version:
According to the cause analysis, the solutions are obtained
(1) Django downgraded to 2.0
(env) PS E:\PythonPro\PyDjangoProDemo011\xuanyuaniotpro> pip install Django==2.0.0 -i https://pypi.douban.com/simple
>>> import django >>> django.VERSION
(env) PS E:\PythonPro\PyDjangoProDemo011\xuanyuaniotpro> python .\manage.py makemigrations No changes detected (env) PS E:\PythonPro\PyDjangoProDemo011\xuanyuaniotpro> (env) PS E:\PythonPro\PyDjangoProDemo011\xuanyuaniotpro> python .\manage.py migrate
Successfully connected to the database.
(2) MySQL upgrade
1. Check the version of MySQL
mysql --version mysql Version 14.14 Distrib 5.5.28, for Linux (x86_64) using reeadline 5.1 As can be seen from the above, MySQL version is 5.5.28
2. View the MySQL installation package
yum list | grep mysql Note: if you do not see the version you want to upgrade, please update the yum installation library as follows: 1) wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm 2) rpm -ivh mysql-community-release-el6-5.noarch.rpm 3) Check it again. Yum list | grep MySQL
3. View the current MySQL installation information
yum list | grep ^mysql Note: the ^ here represents items that start with MySQL ----------- yum info mysql-server It is said that after the execution of the above command, you can see the upgrade version, but you can't see it. ----------- yum check-update mysql-server You can check for available installation packages
4. Upgrade MySQL and its components
yum update mysql-server At the end of execution, keywords such as complete will be displayed.
5. Check whether the update is successful
mysql --version Of course, it doesn't mean that you can use MySQL after this step. Here, there may be a mistake.
When starting the service, the prompt cannot be found mysql.sock And so on.
1. View the error log (premise: my.cnf Log error = path) cat /var/log/mysql_error.log 2. It is found that skip-locking 5.6 is not supported and is out of date. Change to skip external locking (for skip locking, please refer to the link:) 3. Save and exit and restart mysqld service
When the service is started, the error log shows unknown / unsupported storage engine: InnoDB
Execute delete command: RM - RF / var / lib / MySQL / IB* Delete: ibdata1, IB_ logfile0、ib_ Logfile1 file Just restart the service, service mysqld restart
Of course, you may think, if the updated version is 5.5, 5.6 or even higher, but I just want to update to the specified version? What should be done?
In fact, it is very simple. Just change the repo configuration file before updating in the appeal operation.
Configuration file path / etc/ yum.repos .d Modify configuration file: MySQL- community.repo And MySQL community- source.repo Modification content: enable = 1 for the version to be updated and 0 for other versions, as shown in the figure below. Only update to MySQL version 5.6: