当前位置:网站首页>项目连接数据库遇到的问题及解决
项目连接数据库遇到的问题及解决
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)之后再运行那三句命令,就很顺利啦!!!
-----好了,就到这吧,其他问题我也忘了。。。。
边栏推荐
- hutool优雅解析URL链接并获取参数
- The network model established by torch is displayed by torch viz
- Report on Market Research and investment prospects of China's silver powder industry (2022 Edition)
- 按位逻辑运算符
- 【ROS】usb_cam相机标定
- egg. JS project deployment online server
- Guangzhou will promote the construction of a child friendly city, and will explore the establishment of a safe area 200 meters around the school
- Revit 二次开发 HOF 方式调用transaction
- View computer devices in LAN
- Current situation and trend of character animation
猜你喜欢

Crash problem of Chrome browser

Sort according to a number in a string in a column of CSV file

704 binary search

Problems in loading and saving pytorch trained models

Roguelike game into crack the hardest hit areas, how to break the bureau?

win10系统中的截图,win+prtSc保存位置

egg. JS getting started navigation: installation, use and learning

Target detection - pytorch uses mobilenet series (V1, V2, V3) to build yolov4 target detection platform

TP-LINK enterprise router PPTP configuration

The harm of game unpacking and the importance of resource encryption
随机推荐
ROS编译 调用第三方动态库(xxx.so)
可变长参数
堆排序详解
生成器参数传入参数
自动化测试框架有什么作用?上海专业第三方软件测试公司安利
What is CSRF (Cross Site Request Forgery)?
Variable length parameter
Deep anatomy of C language -- C language keywords
MySQL learning record 11jdbcstatement object, SQL injection problem and Preparedstatement object
vb. Net changes with the window, scales the size of the control and maintains its relative position
Guangzhou will promote the construction of a child friendly city, and will explore the establishment of a safe area 200 meters around the school
pcd转ply后在meshlab无法打开,提示 Error details: Unespected eof
LeetCode:394. 字符串解码
Double pointeur en langage C - - modèle classique
LeetCode:41. 缺失的第一个正数
Esp8266-rtos IOT development
LeetCode:124. 二叉树中的最大路径和
LeetCode:162. 寻找峰值
LeetCode:673. 最长递增子序列的个数
Navicat Premium 创建MySql 创建存储过程