当前位置:网站首页>项目连接数据库遇到的问题及解决
项目连接数据库遇到的问题及解决
2022-07-06 08:45:00 【吕大娟】
下载了django-vue-admin项目,想要跑起来,但是一直卡连数据库上,解决了两天,必须要记录一下,给我这个数据库渣渣以后看(呜呜呜呜)
第一个话题
1、首先下面是项目数据库配置,这里注释掉的是原项目中的,我把数据库地址和密码还有数据库名都改了
- 这里的数据库密码指的是你本地安装的数据库服务的密码!!!也就是说你不管在哪拿来的项目,你都要把这个密码先改成你自己的数据库密码(好吧,可能只有我今天才知道悲伤.jpg)
- 数据库名:你要在本地创建一个数据库,起名为django

在数据库链接之前我再说明一点:我用的数据库连接工具是navicat,然后创建数据时有个关系是 数据库连接---->数据库------>表
- 即你要先创建数据库连接(要用到数据库密码、数据库用户名)
- 然后在连接里边创建数据库(要输入数据库名、字符集等)
- 然后在数据库里创建数据表
我真的不想说我一直以为数据库连接就是数据库名,呜呜呜
2、创建数据库连接
再次说明哦哦哦哦哦哦哦


然后双击连接名,连接名变亮,并且能看到一些初始的东西,表示数据库连接创建成功

3、创建数据库
再次说明哦哦哦哦哦哦

这样的话,数据库就创建成功了,下面是我在运行本项目时的创建,其中连接名叫django,数据库名也叫django
第二个话题
----------然后再说说项目中的数据怎么才能在数据库连接工具中出现-------
1、首先肯定是在数据库连接工具中创建数据库(当然宁也可以用命令创建哈),见上一个话题咯
2、创建好之后,再在项目中执行迁移命令和数据初始化命令
- python manage.py makemigrations
- python manage.py migrate
- python manage.py init
执行完这三行命令之后,再刷新数据库,就可以看到项目中的数据表和数据啦
------最后看看这个过程中遇到的问题叭(属于是扒伤口了呜呜呜哭唧唧)-------
当我安装好数据库,以及创建好连接之后,也就是完成了第一个话题中所说的一切之后,在执行python manage.py makemigrations 这个命令时,报错:
MySQLdb._exceptions.OperationalError: (1049, “Unknown database
‘django’”)

问题所在:项目里的数据库叫django(这是数据库名哈),在执行这句命令时,django(这里的django是框架名哈)连接不上你的数据库,因为你的数据库服务器中并没有一个数据库叫django,所以报这个错。
这是因为我以为创建的那个连接就是数据库,所以建完连接之后,就一直执行这个命令啊啊啊啊,我有罪!
创建完数据库(名字当然和项目中写的一样要叫django)之后再运行那三句命令,就很顺利啦!!!
-----好了,就到这吧,其他问题我也忘了。。。。
边栏推荐
- Revit secondary development Hof method calls transaction
- ESP8266-RTOS物联网开发
- Introduction to the differences between compiler options of GCC dynamic library FPIC and FPIC
- Unsupported operation exception
- POI add write excel file
- @JsonBackReference和@JsonManagedReference(解决对象中存在双向引用导致的无限递归)
- C language double pointer -- classic question type
- 电脑F1-F12用途
- Modify the video name from the name mapping relationship in the table
- 【嵌入式】使用JLINK RTT打印log
猜你喜欢

pcd转ply后在meshlab无法打开,提示 Error details: Unespected eof

Indentation of tabs and spaces when writing programs for sublime text

查看局域网中电脑设备

广州推进儿童友好城市建设,将探索学校周边200米设安全区域

Fairguard game reinforcement: under the upsurge of game going to sea, game security is facing new challenges

【嵌入式】使用JLINK RTT打印log

Warning in install. packages : package ‘RGtk2’ is not available for this version of R

Excellent software testers have these abilities

Simple use of promise in uniapp

Guangzhou will promote the construction of a child friendly city, and will explore the establishment of a safe area 200 meters around the school
随机推荐
延迟初始化和密封类
Unsupported operation exception
有效提高软件产品质量,就找第三方软件测评机构
Research Report on supply and demand and development prospects of China's high purity aluminum market (2022 Edition)
sys. argv
Screenshot in win10 system, win+prtsc save location
Target detection - pytorch uses mobilenet series (V1, V2, V3) to build yolov4 target detection platform
Roguelike game into crack the hardest hit areas, how to break the bureau?
China polyether amine Market Forecast and investment strategy report (2022 Edition)
深度剖析C语言指针
ROS compilation calls the third-party dynamic library (xxx.so)
To effectively improve the quality of software products, find a third-party software evaluation organization
LeetCode:221. 最大正方形
Bottom up - physical layer
vb.net 随窗口改变,缩放控件大小以及保持相对位置
visdom可视化实现与检查介绍
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Current situation and trend of character animation
Unified ordering background interface product description Chinese garbled
China high purity silver nitrate Market Research and investment strategy report (2022 Edition)