关注 码龄 粉丝数 原力等级 -- 被采纳 被点赞 采纳率 Arprounce 2024-06-21 11:02
采纳率: 0%
浏览 9 首页/
大数据
/ 数据库迁移前后密码的读取方式不同导致识别到密码是错的 数据库 在项目开发中进行mysql数据库迁移时账户密码正确,权限满足,但是系统提示用户认证失败,无法访问mysql数据库。并且在重启mysql服务之后依然没有解决问题。这里是权限设置:
mysql> GRANT ALL PRIVILEGES ON 2024_06_17_bigdata_subject_weak.* TO 'big_data_weak_user'@'localhost';
Query OK, 0 rows affected (0.02 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.02 sec)
这里是参考网上的修改密码:
mysql> ALTER USER 'big_data_weak_user'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
这里是密码插件设置:
mysql> ALTER USER 'big_data_weak_user'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.02 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.02 sec)
这里是项目的数据库设置: (ps:本人也尝试过使用 Django-environ以及本地配置文件来避免硬编码造成的前后密码读取方式不一致导致的密码识别错误,但是无用)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '2024_06_17_bigdata_subject_weak',#创建的数据库的名字
'USER': 'big_data_weak_user',
'PASSWORD': '123456', #env('Database_Password'),
'HOST':'localhost',
'PORT':'3306',
}
}
使用python3.8.10配置的虚拟环境:
(textmyenv(3.8)) C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system>pip list
Package Version
--------------------- ----------
asgiref 3.2.5
certifi 2018.11.29
chardet 3.0.4
Django 3.0.4
django-environ 0.11.2
django-shortuuidfield 0.1.3
et-xmlfile 1.1.0
furl 1.0.1
idna 2.6
mysqlclient 2.2.4
openpyxl 3.0.10
orderedmultidict 1.0
Pillow 7.0.0
pip 24.0
prettytable 0.7.2
pygame 1.9.6
PyMySQL 0.8.0
python-dateutil 2.7.5
pytz 2018.7
redis 2.10.6
requests 2.18.4
setuptools 69.5.1
shortuuid 0.5.0
six 1.12.0
sqlparse 0.3.1
TimeConvert 1.4.3
tzlocal 1.5.1
urllib3 1.22
virtualenv 16.7.9
wheel 0.43.0
xlrd 1.2.0
下面是原始反馈:
(textmyenv(3.8)) C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system>python manage.py migrate
Traceback (most recent call last):
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection
self.connect()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\db\backends\base\base.py", line 197, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\db\backends\mysql\base.py", line 233, in get_new_connection
return Database.connect(**conn_params)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\__init__.py", line 90, in Connect
return Connection(*args, **kwargs)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\connections.py", line 699, in __init__
self.connect()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\connections.py", line 936, in connect
self._request_authentication()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\connections.py", line 1165, in _request_authentication
auth_packet = self._process_auth(plugin_name, auth_packet)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\connections.py", line 1230, in _process_auth
pkt = self._read_packet()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\connections.py", line 1018, in _read_packet
packet.check_error()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\connections.py", line 384, in check_error
err.raise_mysql_exception(self._data)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.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 21, in
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\core\management\base.py", line 366, in execute
self.check()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\core\management\base.py", line 392, in check
all_issues = self._run_checks(
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\core\management\commands\migrate.py", line 63, in _run_checks
issues = run_checks(tags=[Tags.database])
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\core\checks\database.py", line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\db\backends\mysql\validation.py", line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\db\backends\mysql\validation.py", line 13, in _check_sql_mode
with self.connection.cursor() as cursor:
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\db\backends\base\base.py", line 260, in cursor
return self._cursor()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\db\backends\base\base.py", line 236, in _cursor
self.ensure_connection()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection
self.connect()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\db\utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection
self.connect()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\db\backends\base\base.py", line 197, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\django\db\backends\mysql\base.py", line 233, in get_new_connection
return Database.connect(**conn_params)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\__init__.py", line 90, in Connect
return Connection(*args, **kwargs)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\connections.py", line 699, in __init__
self.connect()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\connections.py", line 936, in connect
self._request_authentication()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\connections.py", line 1165, in _request_authentication
auth_packet = self._process_auth(plugin_name, auth_packet)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\connections.py", line 1230, in _process_auth
pkt = self._read_packet()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\connections.py", line 1018, in _read_packet
packet.check_error()
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\connections.py", line 384, in check_error
err.raise_mysql_exception(self._data)
File "C:\Users\arpro\Desktop\大数据专周数据库\标准模板\day4\student_system\textmyenv(3.8)\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")
展开全部
收起
写回答
好问题
0 提建议
追加酬金
关注问题
微信扫一扫 点击复制链接 分享 邀请回答
编辑 收藏 删除 结题 收藏 举报 追加酬金 (90%的用户在追加酬金后获得了解决方案) 当前问题酬金 ¥ 0
(可追加 ¥500)
¥ 15¥ 20¥ 50¥ 100¥ 200 支付方式 扫码支付
二维码出错
点击刷新
支付金额
15 元
提供问题酬金的用户不参与问题酬金结算和分配
支付即为同意
《付费问题酬金结算规则》 结题 再想想 删除 再等等