• Django迁移文件计算机无法访问虚拟机上的mysql[django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' ([WinError 10061] 由于目标计算机积极拒绝,无法连接。)")]


    (env) D:python_learnmeiduo_projectmeiduo_mall>python manage.py makemigrations
    Traceback (most recent call last):
      File "manage.py", line 22, in <module>
        execute_from_command_line(sys.argv)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagement\__init__.py", line 401, in execute_from_command_line
        utility.execute()
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagement\__init__.py", line 377, in execute
        django.setup()
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjango\__init__.py", line 24, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangoapps
    egistry.py", line 114, in populate
        app_config.import_models()
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangoappsconfig.py", line 211, in import_models
        self.models_module = import_module(models_module_name)
      File "D:PythonPython38libimportlib\__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 783, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocontribauthmodels.py", line 2, in <module>
        from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocontribauthase_user.py", line 47, in <module>
        class AbstractBaseUser(models.Model):
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbmodelsase.py", line 121, in __new__
        new_class.add_to_class('_meta', Options(meta, app_label))
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbmodelsase.py", line 325, in add_to_class
        value.contribute_to_class(cls, name)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbmodelsoptions.py", line 208, in contribute_to_class
        self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodb\__init__.py", line 28, in __getattr__
        return getattr(connections[DEFAULT_DB_ALIAS], item)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbutils.py", line 207, in __getitem__
        backend = load_backend(db['ENGINE'])
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbutils.py", line 111, in load_backend
        return import_module('%s.base' % backend_name)
      File "D:PythonPython38libimportlib\__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsmysqlase.py", line 37, in <module>
        raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
    django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
    
    (env) D:python_learnmeiduo_projectmeiduo_mall>python manage.py makemigrations
    Traceback (most recent call last):
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlconnections.py", line 581, in connect
        sock = socket.create_connection(
      File "D:PythonPython38libsocket.py", line 808, in create_connection
        raise err
      File "D:PythonPython38libsocket.py", line 796, in create_connection
        sock.connect(sa)
    ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsasease.py", line 220, in ensure_connection
        self.connect()
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangoutilsasyncio.py", line 26, in inner
        return func(*args, **kwargs)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsasease.py", line 197, in connect
        self.connection = self.get_new_connection(conn_params)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangoutilsasyncio.py", line 26, in inner
        return func(*args, **kwargs)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsmysqlase.py", line 233, in get_new_connection
        return Database.connect(**conn_params)
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysql\__init__.py", line 94, in Connect
        return Connection(*args, **kwargs)
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlconnections.py", line 325, in __init__
        self.connect()
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlconnections.py", line 630, in connect
        raise exc
    pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' ([WinError 10061] 由于目标计算机积极拒绝,无法连接。)")
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "manage.py", line 22, in <module>
        execute_from_command_line(sys.argv)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagement\__init__.py", line 401, in execute_from_command_line
        utility.execute()
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagement\__init__.py", line 395, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagementase.py", line 328, in run_from_argv
        self.execute(*args, **cmd_options)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagementase.py", line 366, in execute
        self.check()
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagementase.py", line 392, in check
        all_issues = self._run_checks(
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocoremanagementase.py", line 382, in _run_checks
        return checks.run_checks(**kwargs)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocorechecks
    egistry.py", line 72, in run_checks
        new_errors = check(app_configs=app_configs)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangocorechecksmodel_checks.py", line 34, in check_all_models
        errors.extend(model.check(**kwargs))
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbmodelsase.py", line 1275, in check
        *cls._check_constraints(),
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbmodelsase.py", line 1843, in _check_constraints
        connection.features.supports_table_check_constraints or
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangoutilsfunctional.py", line 48, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsmysqlfeatures.py", line 93, in supports_column_check_constraints
        if self.connection.mysql_is_mariadb:
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangoutilsfunctional.py", line 48, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsmysqlase.py", line 363, in mysql_is_mariadb
        return 'mariadb' in self.mysql_server_info.lower()
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangoutilsfunctional.py", line 48, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsmysqlase.py", line 350, in mysql_server_info
        with self.temporary_connection() as cursor:
      File "D:PythonPython38libcontextlib.py", line 113, in __enter__
        return next(self.gen)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsasease.py", line 604, in temporary_connection
        with self.cursor() as cursor:
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangoutilsasyncio.py", line 26, in inner
        return func(*args, **kwargs)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsasease.py", line 260, in cursor
        return self._cursor()
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsasease.py", line 236, in _cursor
        self.ensure_connection()
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangoutilsasyncio.py", line 26, in inner
        return func(*args, **kwargs)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsasease.py", line 220, in ensure_connection
        self.connect()
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbutils.py", line 90, in __exit__
        raise dj_exc_value.with_traceback(traceback) from exc_value
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsasease.py", line 220, in ensure_connection
        self.connect()
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangoutilsasyncio.py", line 26, in inner
        return func(*args, **kwargs)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsasease.py", line 197, in connect
        self.connection = self.get_new_connection(conn_params)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangoutilsasyncio.py", line 26, in inner
        return func(*args, **kwargs)
      File "D:python_learnmeiduo_projectenvlibsite-packagesdjangodbackendsmysqlase.py", line 233, in get_new_connection
        return Database.connect(**conn_params)
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysql\__init__.py", line 94, in Connect
        return Connection(*args, **kwargs)
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlconnections.py", line 325, in __init__
        self.connect()
      File "D:python_learnmeiduo_projectenvlibsite-packagespymysqlconnections.py", line 630, in connect
        raise exc
    django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' ([WinError 10061] 由于目标计算机积极拒绝,无法连接。)")

     使用服务器ip,不要使用127.0.0.1

  • 相关阅读:
    不要随便用#define 沉沉_
    转载堆和栈的区别 沉沉_
    转载include包含源文件引发的错误 沉沉_
    浅议C和C++中的内存分配 沉沉_
    volatile 的应用 沉沉_
    Debian显示txt乱码
    Debian 64位安装wink
    Debian安装vmware虚拟机
    Debian安装scim中文、日语输入法
    Debian安装chrome
  • 原文地址:https://www.cnblogs.com/sewen-H/p/13335344.html
Copyright © 2020-2023  润新知