你好,我是 Kagol,个人公众号:前端开源星球(欢迎关注我,分享更多前端开源知识)。
TinyPro 后台管理系统的 NestJS 后端依赖 MySQL 和 Redis 数据库,本文主要带大家安装和启动 MySQL 和 Redis 数据库。
macOS
如果你使用的是 macOS 操作系统,安装 MySQL 和 Redis 数据库将变得非常简单,只需要一行命令即可。
MySQL
安装 MySQL:查看是否安装成功:- $ mysql --version
- mysql Ver 9.2.0 for macos13.7 on x86_64 (Homebrew)
复制代码 启动 MySQL:- $ brew services start mysql
- ==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
复制代码 连接 MySQL 数据库:退出 MySQL 终端:停止数据库:- $ brew services stop mysql
- Stopping `mysql`... (might take a while)
- ==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)
复制代码 Redis
得益于 macOS 的 Homebrew 软件包管理器,Redis 数据库的安装和启动和 MySQL 一样简单。
安装 Redis:查看 Redis 是否安装成功:- $ redis-cli --version
- redis-cli 7.2.7
复制代码 启动 Redis:- $ brew services start redis
- ==> Successfully started `redis` (label: homebrew.mxcl.redis)
复制代码 验证是否启动成功:- $ redis-cli
- 127.0.0.1:6379> ping
- PONG
- 127.0.0.1:6379>
复制代码 退出 Redis 终端:停止 Redis:- $ brew services stop redis
- Stopping `redis`... (might take a while)
- ==> Successfully stopped `redis` (label: homebrew.mxcl.redis)
复制代码 Windows
如果你使用的是 Windows 操作系统,你需要先下载 MySQL 和 Redis 对应的软件包。
MySQL
下载软件包:https://downloads.mysql.com/archives/installer/
点击文件:mysql-installer-community-8.0.40.0.msi 进行安装。
安装完成之后,在终端中执行以下命令连接数据库。Redis
下载软件包:https://github.com/redis-windows/redis-windows/releases
将文件:Redis-7.4.2-Windows-x64-cygwin.zip 进行解压。
点击文件:redis-server.exe 即可启动 Redis,不需要安装。
往期文章
- OpenTiny 开源社区招募贡献者啦!
- TinyPro Vue v1.1.0 正式发布:增加细粒度权限管理、页签模式、多级菜单,支持 Webpack/Vite/Rspack/Farm 多种构建工具
- 优化永不止步:TinyVue v3.20.0 正式发布,更美观的官网UI,更友好的文档搜索,更强大的主题配置能力
- TinyEditor v3.25.0 正式发布!2025年第一个版本,增加标题列表导航、分隔线、多图多文件上传等实用特性
联系我们
GitHub:https://github.com/opentiny/tiny-pro(欢迎 Star ⭐)
官网:https://opentiny.design/vue-pro
个人博客:https://kagol.github.io/blogs
小助手微信:opentiny-official
公众号:OpenTiny
附录:MySQL 数据库基本操作
显示所有数据库:- mysql> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | demo_tiny_pro |
- | information_schema |
- | mysql |
- | order_sys |
- | performance_schema |
- | sys |
- +--------------------+
- 6 rows in set (0.09 sec)
复制代码 创建数据库:- mysql> create database order_sys;
- Query OK, 1 row affected (0.01 sec)
复制代码 删除数据库:- mysql> drop database order_sys;
- Query OK, 0 rows affected (0.01 sec)
复制代码 使用数据库:- mysql> use order_sys;
- Reading table information for completion of table and column names
- You can turn off this feature to get a quicker startup with -A
- Database changed
复制代码 显示当前数据库下的所有数据表:- mysql> show tables;
- +---------------------+
- | Tables_in_order_sys |
- +---------------------+
- | lang |
- | menu |
- | order |
- | permission |
- | role |
- | role_menu |
- | role_permission |
- | user |
- | user_role |
- +---------------------+
- 9 rows in set (0.00 sec)
复制代码 从数据表中查询数据:- mysql> select id,name from menu;
- +----+---------------+
- | id | name |
- +----+---------------+
- | 1 | Board |
- | 2 | Home |
- | 3 | Work |
- | 4 | List |
- | 5 | Table |
- | 6 | Form |
- | 7 | Base |
- | 8 | Step |
- | 9 | Profile |
- | 10 | Detail |
- +----+---------------+
- 10 rows in set (0.00 sec)
复制代码 来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |