Error Messages:
PS D:\test\orchard_liang>python manage.py sqlmigrate app 0001
Traceback (most recent call last):
File "D:\Python37\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "D:\Python37\lib\site-packages\django\utils\asyncio.py", line 33, in inner
return func(*args, **kwargs)
File "D:\Python37\lib\site-packages\django\db\backends\base\base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "D:\Python37\lib\site-packages\django\utils\asyncio.py", line 33, in inner
return func(*args, **kwargs)
File "D:\Python37\lib\site-packages\django\db\backends\mysql\base.py", line 234, in get_new_connection
connection = Database.connect(**conn_params)
File "D:\Python37\lib\site-packages\MySQLdb\__init__.py", line 84, in Connect
return Connection(*args, **kwargs)
File "D:\Python37\lib\site-packages\MySQLdb\connections.py", line 179, in __init__
super(Connection, self).__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2026, 'SSL connection error: unknown error number')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "D:\Python37\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "D:\Python37\lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Python37\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Python37\lib\site-packages\django\core\management\commands\sqlmigrate.py", line 29, in execute
return super().execute(*args, **options)
File "D:\Python37\lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "D:\Python37\lib\site-packages\django\core\management\commands\sqlmigrate.py", line 37, in handle
loader = MigrationLoader(connection, replace_migrations=False)
File "D:\Python37\lib\site-packages\django\db\migrations\loader.py", line 53, in __init__
self.build_graph()
File "D:\Python37\lib\site-packages\django\db\migrations\loader.py", line 220, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "D:\Python37\lib\site-packages\django\db\migrations\recorder.py", line 77, in applied_migrations
if self.has_table():
File "D:\Python37\lib\site-packages\django\db\migrations\recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "D:\Python37\lib\site-packages\django\utils\asyncio.py", line 33, in inner
return func(*args, **kwargs)
File "D:\Python37\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
return self._cursor()
File "D:\Python37\lib\site-packages\django\db\backends\base\base.py", line 235, in _cursor
self.ensure_connection()
File "D:\Python37\lib\site-packages\django\utils\asyncio.py", line 33, in inner
return func(*args, **kwargs)
File "D:\Python37\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "D:\Python37\lib\site-packages\django\db\utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "D:\Python37\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "D:\Python37\lib\site-packages\django\utils\asyncio.py", line 33, in inner
return func(*args, **kwargs)
File "D:\Python37\lib\site-packages\django\db\backends\base\base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "D:\Python37\lib\site-packages\django\utils\asyncio.py", line 33, in inner
return func(*args, **kwargs)
File "D:\Python37\lib\site-packages\django\db\backends\mysql\base.py", line 234, in get_new_connection
connection = Database.connect(**conn_params)
File "D:\Python37\lib\site-packages\MySQLdb\__init__.py", line 84, in Connect
return Connection(*args, **kwargs)
File "D:\Python37\lib\site-packages\MySQLdb\connections.py", line 179, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2026, 'SSL connection error: unknown error number')
Reason: SSL of the higher versions of MySQL is turned on by default
solution: turn off SSL
Step 1: check the SSL startup first
Login mysql and then enter the commands below:
mysql> SHOW VARIABLES LIKE '%ssl%';
Step 2: Modify the configuration file my.ini
# PATH: C:\ProgramData\MySQL\MySQL Server 8.0
[mysqld]
skip_ssl # ssl
Step 3: restart MySQL service
ctrl+shift+esc key to call up task manager -> services -> find mysql service -> right click and rerun
Step 4: re execute the command:
mysql> SHOW VARIABLES LIKE '%ssl%';