老师报错了
import mysql.connector
con = mysql.connector.connect(
host="localhost",port="3306",user="root",password="abc123456",database="demo"
)
con.close()
D:\untitled1\demo_1\venv\Scripts\python.exe D:/untitled1/demo_1/example_1.py
Traceback (most recent call last):
File "D:\python\lib\site-packages\mysql\connector\connection_cext.py", line 216, in _open_connection
self._cmysql.connect(**cnx_kwargs)
_mysql_connector.MySQLInterfaceError: Access denied for user 'root'@'localhost' (using password: YES)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/untitled1/demo_1/example_1.py", line 2, in <module>
con = mysql.connector.connect(
File "D:\python\lib\site-packages\mysql\connector\__init__.py", line 264, in connect
return CMySQLConnection(*args, **kwargs)
File "D:\python\lib\site-packages\mysql\connector\connection_cext.py", line 80, in __init__
self.connect(**kwargs)
File "D:\python\lib\site-packages\mysql\connector\abstracts.py", line 960, in connect
self._open_connection()
File "D:\python\lib\site-packages\mysql\connector\connection_cext.py", line 218, in _open_connection
raise errors.get_mysql_exception(msg=exc.msg, errno=exc.errno,
mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Process finished with exit code 1
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 625 份
- 解答问题 2669 个
数据库作为企业储存和管理数据的根本,掌握数据库是每个开发工程师必备的技能,本阶段带你学会用Python操作MySQL、Redis和MongoDB三大主流数据库。夯实数据库基础。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星