python mysql 添加用户名密码

编程入门 行业动态 更新时间:2024-10-19 18:27:33

python mysql 添加<a href=https://www.elefans.com/category/jswz/34/1770444.html style=用户名密码"/>

python mysql 添加用户名密码

项目和应用创建好以后,进入当前的目录所在的文件夹即可操作,也可以用pycharm中的Tools工具运行manage.py,本人采用的是运行pycharm下的manage.py文件

配置:

1.把对应的应用添加到INSTALLED_APPS下,注意分号

INSTALLED_APPS = [

'django.contrib.admin',

'django.contrib.auth',

'django.contrib.contenttypes',

'django.contrib.sessions',

'django.contrib.messages',

'django.contrib.staticfiles',

'blog', #应用

]

2.修改数据库连接

DATABASES = {

'default': {

'ENGINE': 'django.db.backends.mysql', # 提示连接mysql数据库

'NAME': 'test', # 数据库名为test,要自己创建

'USER': 'root', # 用户名

'PASSWORD': 'root',# 密码

'HOST': '127.0.0.1', # 连接的主机

'PORT': '3306', # 对应的端口号

}

}

运行:

manage.py@hello_mysite > migrate # 连接数据库

"D:\pycharm\PyCharm 5.0.3\bin\runnerw.exe" D:\python\python.exe "D:\pycharm\PyCharm 5.0.3\helpers\pycharm\django_manage.py" migrate G:/hello_mysite

Operations to perform:

Apply all migrations: admin, auth, contenttypes, sessions

Running migrations:

Applying contenttypes.0001_initial... OK

Applying auth.0001_initial... OK

Applying admin.0001_initial... OK

Applying admin.0002_logentry_remove_auto_add... OK

Applying contenttypes.0002_remove_content_type_name... OK

Applying auth.0002_alter_permission_name_max_length... OK

Applying auth.0003_alter_user_email_max_length... OK

Applying auth.0004_alter_user_username_opts... OK

Applying auth.0005_alter_user_last_login_null... OK

Applying auth.0006_require_contenttypes_0002... OK

Applying auth.0007_alter_validators_add_error_messages... OK

Applying auth.0008_alter_user_username_max_length... OK

Applying sessions.0001_initial... OK

Process finished with exit code 0

manage.py@hello_mysite > makemigrations blog # 关联应用

"D:\pycharm\PyCharm 5.0.3\bin\runnerw.exe" D:\python\python.exe "D:\pycharm\PyCharm 5.0.3\helpers\pycharm\django_manage.py" makemigrations blog G:/hello_mysite

No changes detected in app 'blog'

Process finished with exit code 0

manage.py@hello_mysite > createsuperuser # 创建超级用户

"D:\pycharm\PyCharm 5.0.3\bin\runnerw.exe" D:\python\python.exe "D:\pycharm\PyCharm 5.0.3\helpers\pycharm\django_manage.py" createsuperuser G:/hello_mysite

Username: root # 用户名

Email address: root@root # 邮箱

Warning: Password input may be echoed.

Password: root1234 # 密码,不要太短

Warning: Password input may be echoed.

Password (again): root1234 # 再次输入

Superuser created successfully. 到此,一次OK了!!

更多推荐

python mysql 添加用户名密码

本文发布于:2024-03-15 08:09:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1738454.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户名   密码   python   mysql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!