gpt4 book ai didi

Python mysql xampp

转载 作者:行者123 更新时间:2023-11-29 03:22:25 25 4
gpt4 key购买 nike

我安装了 xampp 服务器。我想通过python访问MySQL数据库。我试图安装 MySQL-python 包。它需要我不想安装的 visual studio。

我尝试通过 MySQL 连接器,但不允许这样做。

如何通过python访问MySQL数据库?

最佳答案

你可以这样试试,

db=MySQLdb.connect(user="user_name",passwd="password",db="database_name",unix_socket="mysql.sock file path")

或者尝试运行,python manage.py runserver

或者检查一下数据库的默认设置

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'database_name', # Or path to database file if using sqlite3.
'USER': 'user_name', # Not used with sqlite3.
'PASSWORD': 'password', # Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '3306' # Set to empty string for default. Not used with sqlite3.
}
}

关于Python mysql xampp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41971988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com