python manage.py migrate (error) - mysql

I have trouble when I execute the command python migrate.py migrate.
I'm learning a little about django, and I need synchronize django with a mysql database.
In settings.py file, I put the right database, username and root password, I don't know why is not having access for root.
So here's my error:
(Ambientepython3) leonardo.oliveira#dss-skinner:~/django-tutorials/mysite$ python manage.py migrate
Traceback (most recent call last):
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 229, in get_new_connection
return Database.connect(**conn_params)
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/MySQLdb/__init__.py", line 86, in Connect
return Connection(*args, **kwargs)
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/MySQLdb/connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1698, "Access denied for user 'root'#'localhost'")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/management/base.py", line 350, in execute
self.check()
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/management/base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 59, in _run_checks
issues = run_checks(tags=[Tags.database])
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/checks/registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/checks/database.py", line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/mysql/validation.py", line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/mysql/validation.py", line 13, in _check_sql_mode
with self.connection.cursor() as cursor:
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 255, in cursor
return self._cursor()
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 232, in _cursor
self.ensure_connection()
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 229, in get_new_connection
return Database.connect(**conn_params)
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/MySQLdb/__init__.py", line 86, in Connect
return Connection(*args, **kwargs)
File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/MySQLdb/connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1698, "Access denied for user 'root'#'localhost'")

Related

MySQL Connection Error with Cpanel Hosting

I'm trying to connect my application with MySQL Database engine on Cpanel hosting platform but every time I tried to run makemigrations there's always this long error:
Traceback (most recent call last):
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 244, in ensure_connection
self.connect()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 225, in connect
self.connection = self.get_new_connection(conn_params)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/django/base.py", line 366, in get_new_connection
cnx = mysql.connector.connect(**conn_params)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/pooling.py", line 286, in connect
return CMySQLConnection(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/connection_cext.py", line 101, in __init__
self.connect(**kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/abstracts.py", line 1099, in connect
self._post_connection()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/abstracts.py", line 1071, in _post_connection
self.set_charset_collation(self._charset_id)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/abstracts.py", line 1016, in set_charset_collation
) = CharacterSet.get_charset_info(charset)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/constants.py", line 775, in get_charset_info
info = cls.get_default_collation(charset)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/constants.py", line 746, in get_default_collation
raise ProgrammingError(f"Character set '{charset}' unsupported")
mysql.connector.errors.ProgrammingError: Character set '255' unsupported
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home2/cmsmcsc1/cmsmcs/manage.py", line 22, in <module>
main()
File "/home2/cmsmcsc1/cmsmcs/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/core/management/base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/core/management/base.py", line 460, in execute
output = self.handle(*args, **options)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/core/management/base.py", line 98, in wrapped
res = handle_func(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/core/management/commands/makemigrations.py", line 119, in handle
loader.check_consistent_history(connection)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/migrations/loader.py", line 313, in check_consistent_history
applied = recorder.applied_migrations()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 81, in applied_migrations
if self.has_table():
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 57, in has_table
with self.connection.cursor() as cursor:
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 284, in cursor
return self._cursor()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 260, in _cursor
self.ensure_connection()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 244, in ensure_connection
self.connect()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 244, in ensure_connection
self.connect()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 225, in connect
self.connection = self.get_new_connection(conn_params)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/django/base.py", line 366, in get_new_connection
cnx = mysql.connector.connect(**conn_params)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/pooling.py", line 286, in connect
return CMySQLConnection(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/connection_cext.py", line 101, in __init__
self.connect(**kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/abstracts.py", line 1099, in connect
self._post_connection()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/abstracts.py", line 1071, in _post_connection
self.set_charset_collation(self._charset_id)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/abstracts.py", line 1016, in set_charset_collation
) = CharacterSet.get_charset_info(charset)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/constants.py", line 775, in get_charset_info
info = cls.get_default_collation(charset)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/constants.py", line 746, in get_default_collation
raise ProgrammingError(f"Character set '{charset}' unsupported")
django.db.utils.ProgrammingError: (-1, "Character set '255' unsupported", None)
Does anyone knows what to do, please?
try it it will definitely helps you
run the command in your Cpanel Hosting Terminal
pip3 install mysql-connector-python==8.0.29

Django Python LoadData: Error Problem Installing Fixture

First I have migrate and makemigrations and then I have dump data with this command:
python manage.py dumpdata --exclude auth.permission --exclude contenttypes > dvvv.json
I have tried to flush the database but when I execute python manage.py loaddata dvvv.json the following error occurs:
pymysql.err.ProgrammingError: (1146, "Table 'webcnytc_prilert_tool.Prilert_confirmationemail' doesn't exist")
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 "/root/Django/my_env/lib/python3.7/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/root/Django/my_env/lib/python3.7/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/root/Django/my_env/lib/python3.7/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/root/Django/my_env/lib/python3.7/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/root/Django/my_env/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 78, in handle
self.loaddata(fixture_labels)
File "/root/Django/my_env/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 123, in loaddata
self.load_label(fixture_label)
File "/root/Django/my_env/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 190, in load_label
obj.save(using=self.using)
File "/root/Django/my_env/lib/python3.7/site-packages/django/core/serializers/base.py", line 223, in save
models.Model.save_base(self.object, using=using, raw=True, **kwargs)
File "/root/Django/my_env/lib/python3.7/site-packages/django/db/models/base.py", line 778, in save_base
force_update, using, update_fields,
File "/root/Django/my_env/lib/python3.7/site-packages/django/db/models/base.py", line 859, in _save_table
forced_update)
File "/root/Django/my_env/lib/python3.7/site-packages/django/db/models/base.py", line 912, in _do_update
return filtered._update(values) > 0
File "/root/Django/my_env/lib/python3.7/site-packages/django/db/models/query.py", line 802, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/root/Django/my_env/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1559, in execute_sql
cursor = super().execute_sql(result_type)
File "/root/Django/my_env/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
cursor.execute(sql, params)
File "/root/Django/my_env/lib/python3.7/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/root/Django/my_env/lib/python3.7/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/root/Django/my_env/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/root/Django/my_env/lib/python3.7/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/root/Django/my_env/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/root/Django/my_env/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 73, in execute
return self.cursor.execute(query, args)
File "/root/Django/my_env/lib/python3.7/site-packages/pymysql/cursors.py", line 148, in execute
result = self._query(query)
File "/root/Django/my_env/lib/python3.7/site-packages/pymysql/cursors.py", line 310, in _query
conn.query(q)
File "/root/Django/my_env/lib/python3.7/site-packages/pymysql/connections.py", line 548, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/root/Django/my_env/lib/python3.7/site-packages/pymysql/connections.py", line 775, in _read_query_result
result.read()
File "/root/Django/my_env/lib/python3.7/site-packages/pymysql/connections.py", line 1156, in read
first_packet = self.connection._read_packet()
File "/root/Django/my_env/lib/python3.7/site-packages/pymysql/connections.py", line 725, in _read_packet
packet.raise_for_error()
File "/root/Django/my_env/lib/python3.7/site-packages/pymysql/protocol.py", line 221, in raise_for_error
err.raise_mysql_exception(self._data)
File "/root/Django/my_env/lib/python3.7/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
raise errorclass(errno, errval)
django.db.utils.ProgrammingError: Problem installing fixture '/root/Django/dvvv.json': Could not load Prilert.ConfirmationEmail(pk=137): (1146, "Table 'webcnytc_prilert_tool.Prilert_confirmationemail' doesn't exist")

Airflow initdb with mysql as backend is not working

when I initialize airflow using mysql as backend I see below error
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py",
line 453, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.7/site-packages/MySQLdb/init.py", line 80,
in Connect
from MySQLdb.connections import Connection
File "/usr/local/lib/python3.7/site-packages/MySQLdb/connections.py", line
36
raise errorclass, errorvalue
^
SyntaxError: invalid syntax
I tried re-installing mysql-python and pymysql still its same
airflow initdb
/usr/local/lib/python3.7/site-packages/airflow/configuration.py:627: DeprecationWarning: You have two airflow.cfg files: /home/airflow/airflow/airflow.cfg and /home/airflow/airflow.cfg. Airflow used to look at ~/airflow/airflow.cfg, even when AIRFLOW_HOME was set to a different value. Airflow will now only read /home/airflow/airflow.cfg, and you should remove the other file
category=DeprecationWarning,
[2019-09-24 12:10:32,310] {settings.py:213} INFO - settings.configure_orm(): Using pool settings. pool_size=5, max_overflow=10, pool_recycle=1800, pid=15403
[2019-09-24 12:10:32,508] {__init__.py:51} INFO - Using executor LocalExecutor
DB: mysql://airdba:***#host/airflow_main
[2019-09-24 12:10:32,820] {db.py:369} INFO - Creating tables
Traceback (most recent call last):
File "/usr/local/bin/airflow", line 32, in <module>
args.func(args)
File "/usr/local/lib/python3.7/site-packages/airflow/bin/cli.py", line 1102, in initdb
db.initdb(settings.RBAC)
File "/usr/local/lib/python3.7/site-packages/airflow/utils/db.py", line 106, in initdb
upgradedb()
File "/usr/local/lib/python3.7/site-packages/airflow/utils/db.py", line 377, in upgradedb
command.upgrade(config, 'heads')
File "/usr/local/lib/python3.7/site-packages/alembic/command.py", line 298, in upgrade
script.run_env()
File "/usr/local/lib/python3.7/site-packages/alembic/script/base.py", line 489, in run_env
util.load_python_file(self.dir, "env.py")
File "/usr/local/lib/python3.7/site-packages/alembic/util/pyfiles.py", line 98, in load_python_file
module = load_module_py(module_id, path)
File "/usr/local/lib/python3.7/site-packages/alembic/util/compat.py", line 173, in load_module_py
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.7/site-packages/airflow/migrations/env.py", line 92, in <module>
run_migrations_online()
File "/usr/local/lib/python3.7/site-packages/airflow/migrations/env.py", line 78, in run_migrations_online
with connectable.connect() as connection:
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2206, in connect
return self._connection_cls(self, **kwargs)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 103, in __init__
else engine.raw_connection()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2306, in raw_connection
self.pool.unique_connection, _connection
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2275, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 303, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 760, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 492, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
self._dec_overflow()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
raise value
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 437, in __init__
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 639, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 453, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.7/site-packages/MySQLdb/__init__.py", line 80, in Connect
from MySQLdb.connections import Connection
File "/usr/local/lib/python3.7/site-packages/MySQLdb/connections.py", line 36
raise errorclass, errorvalue
^
SyntaxError: invalid syntax
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 437, in __init__
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 639, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 453, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.7/site-packages/MySQLdb/__init__.py", line 80, in Connect
from MySQLdb.connections import Connection
File "/usr/local/lib/python3.7/site-packages/MySQLdb/connections.py", line 36
raise errorclass, errorvalue
^
SyntaxError: invalid syntax
removed mysql-python module and forced airflow to use pymysql.
changed connection string in airflow.cfg
sql_alchemy_conn = mysql+pymysql://user:password#server/dbname

Django migartion fail, (2013, 'Lost connection to MySQL server at \'reading initial communication packet\')

The company work had bought domain name under NameCheap (no Root access)
All I now need is setup the database and webpage will be working
My company system use:
Apache Version: 2.4.38
MySQL Version: 10.1.38-MariaDB-cll-lve
Architecture: x86_64
Operating System: Linux
Python: 3.7
Django: 2.1.7
but when I run python manage.py migrate
I had this error:
Traceback (most recent call last):
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 227, in get_new_connection
return Database.connect(**conn_params)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/MySQLdb/__init__.py", line 84, in Connect
return Connection(*args, **kwargs)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/MySQLdb/connections.py", line 164, in __init__
super(Connection, self).__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2013, 'Lost connection to MySQL server at \'reading initial communication packet\', system error: 2 "No such file or directory"')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 350, in execute
self.check()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 59, in _run_checks
issues = run_checks(tags=[Tags.database])
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/checks/registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/checks/database.py", line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/mysql/validation.py", line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/mysql/validation.py", line 13, in _check_sql_mode
with self.connection.cursor() as cursor:
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 255, in cursor
return self._cursor()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 232, in _cursor
self.ensure_connection()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 227, in get_new_connection
return Database.connect(**conn_params)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/MySQLdb/__init__.py", line 84, in Connect
return Connection(*args, **kwargs)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/MySQLdb/connections.py", line 164, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server at \'reading initial communication packet\', system error: 2 "No such file or directory"')
I did some searching on StackOverflow:
Error during Django "Running migrations": django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')
Trouble closing and reopening MySQL connection after catching/handling django.db.utils.OperationalError (2013, Lost connection to server)
but it was not very helpfully
further digging on the subject lead to me believe that MYSQL database is denying the access to my Django app.
I could try this theory as I don't access to MYSQL setting at all
To summarzie; I need migrate on django app but I had error running the command.
Help, please, I really appracite if you could help me with this.
I'm new to coding. Maybe you make a beginner mistake?
mismatch of the word? Include, cap underline?
I don't know if I was helping.
Just suggesting
This could cause by MYSQL DB having a time.
you correct this by going into the MySQL Workbench and set long DMSB.
Here the link on article responding to this error:
https://anothercoffee.net/fix-error-code-2013-lost-connection-mysql-server-query/
The mysql official document on this issue;
https://dev.mysql.com/doc/refman/5.7/en/error-lost-connection.html
Hope this help

python manage.py migrate throwing error using xamp (phpmyadmin) with Django in windows 10

Python Version - 3.7.2
Django Version - 2.1.5
I am getting the error below after command >python manage.py migrate
please find the attached error message.
(py1) C:\Users\tejra\Documents\DjangoProject\Dproject>python manage.py migrate
Traceback (most recent call last):
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
self.connect()
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\db\backends\mysql\base.py", line 227, in get_new_connection
return Database.connect(**conn_params)
File "C:\Users\tejra\Envs\py1\lib\site-packages\MySQLdb\__init__.py", line 85, in Connect
return Connection(*args, **kwargs)
File "C:\Users\tejra\Envs\py1\lib\site-packages\MySQLdb\connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'#'localhost' (using password: YES)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\core\management\base.py", line 350, in execute
self.check()
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\core\management\base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\core\management\commands\migrate.py", line 59, in _run_checks
issues = run_checks(tags=[Tags.database])
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\core\checks\registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\core\checks\database.py", line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\db\backends\mysql\validation.py", line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\db\backends\mysql\validation.py", line 13, in _check_sql_mode
with self.connection.cursor() as cursor:
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 255, in cursor
return self._cursor()
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 232, in _cursor
self.ensure_connection()
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
self.connect()
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\db\utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
self.connect()
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\tejra\Envs\py1\lib\site-packages\django\db\backends\mysql\base.py", line 227, in get_new_connection
return Database.connect(**conn_params)
File "C:\Users\tejra\Envs\py1\lib\site-packages\MySQLdb\__init__.py", line 85, in Connect
return Connection(*args, **kwargs)
File "C:\Users\tejra\Envs\py1\lib\site-packages\MySQLdb\connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1045, "Access denied for user 'root'#'localhost' (using password: YES)")