contos+装mysql_5分钟完成 centos 安装strapi+mysql数据连接

strapi 是一个开源的内容管理平台,功能操作起来还是比较方便简单的,提供一系列的api,方便用来做一些小程序接口或者应用程序的数据保存接口。

软件版本最低要求

Node.js  12.x  , npm   6.x

数据库要求:SQLite 3,PostgreSQL 10,MySQL 5.6,MariaDB 10.1,MongoDB 3.6

如果数据量不大,直接用SQLite,不需要安装其他数据库

1.首先安装nodejs v15 和yarn.

curl -sL https://rpm.nodesource.com/setup_14.x | bash -

yum -y install nodejs

curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

yum install yarn

2.启动一个strapi项目

创建项目

yarn create strapi-app my-project --quickstart

进入 my-project 目录,安装mysql依赖

npm install mysql --save

修改配置文件

strapi/config/database.js

module.exports = ({ env }) => ({

defaultConnection: 'default',

connections: {

default: {

connector: 'bookshelf',

settings: {

"client": "mysql",

"database": "test",

"host": "localhost",

"port": "3306",

"username": "test",

"password": "test"

},

options: {

useNullAsDefault: true,

},

},

},

})

启动项目

yarn develop

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值