当前位置:网站首页>项目连接数据库遇到的问题及解决
项目连接数据库遇到的问题及解决
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)之后再运行那三句命令,就很顺利啦!!!
-----好了,就到这吧,其他问题我也忘了。。。。
边栏推荐
- [NVIDIA development board] FAQ (updated from time to time)
- Hutool gracefully parses URL links and obtains parameters
- To effectively improve the quality of software products, find a third-party software evaluation organization
- Introduction to the differences between compiler options of GCC dynamic library FPIC and FPIC
- pytorch训练好的模型在加载和保存过程中的问题
- 深度剖析C语言数据在内存中的存储
- sublime text没关闭其他运行就使用CTRL+b运行另外的程序问题
- egg. JS getting started navigation: installation, use and learning
- How to conduct interface test? What are the precautions? Nanny level interpretation
- The problem and possible causes of the robot's instantaneous return to the origin of the world coordinate during rviz simulation
猜你喜欢

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

MySQL learning record 10getting started with JDBC

JVM 快速入门

Using pkgbuild:: find in R language_ Rtools check whether rtools is available and use sys The which function checks whether make exists, installs it if not, and binds R and rtools with the writelines

深度剖析C语言指针

JVM performance tuning and practical basic theory - Part 1

MySQL learning records 12jdbc operation transactions

sublime text的编写程序时的Tab和空格缩进问题

【嵌入式】Cortex M4F DSP库

Analysis of the source code of cocos2d-x for mobile game security (mobile game reverse and protection)
随机推荐
gcc动态库fPIC和fpic编译选项差异介绍
被破解毁掉的国产游戏之光
Simple use of promise in uniapp
Introduction to the differences between compiler options of GCC dynamic library FPIC and FPIC
Generator parameters incoming parameters
Bottom up - physical layer
To effectively improve the quality of software products, find a third-party software evaluation organization
【Nvidia开发板】常见问题集 (不定时更新)
The problem and possible causes of the robot's instantaneous return to the origin of the world coordinate during rviz simulation
Light of domestic games destroyed by cracking
LeetCode:124. 二叉树中的最大路径和
个人电脑好用必备软件(使用过)
LeetCode:162. 寻找峰值
PC easy to use essential software (used)
C語言雙指針——經典題型
LeetCode:387. 字符串中的第一个唯一字符
egg. JS project deployment online server
vb. Net changes with the window, scales the size of the control and maintains its relative position
MySQL learning record 10getting started with JDBC
@JsonBackReference和@JsonManagedReference(解决对象中存在双向引用导致的无限递归)