在idea中關聯已有的資料庫
- 開啟Database

- 選擇相應的資料庫
點選 +> Data Source> MySQL

- 填寫要連結的資料庫名稱、使用者名稱和密碼
- Host: localhost port: 3306
- Database: netease
- User: root
- Password: 密碼

- 下載或者更新驅動

在idea中,通過執行sql指令碼來新建專案所需要的資料庫
- 開啟Database
- 選擇相應的資料庫
- 第三部和連結已有的資料庫不一樣了,因為是新建資料庫,所以不填寫資料庫名稱
- 右鍵
schemas
,點選Run SQL Script...
指令碼內容:
SET FOREIGN_KEY_CHECKS=0;
DROP DATABASE IF EXISTS `mall`;
CREATE DATABASE `mall`;
USE mall;
DROP TABLE IF EXISTS `cms_help`;
CREATE TABLE `cms_help` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`category_id` bigint(20) DEFAULT NULL,
`icon` varchar(500) DEFAULT NULL,
`title` varchar(100) DEFAULT NULL,
`show_status` int(1) DEFAULT NULL,
`create_time` datetime DEFAULT NULL,
`read_count` int(1) DEFAULT NULL,
`content` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='幫助表';
複製程式碼
- 然後修改資料庫的配置,去關聯剛新建的資料庫


Database: mall
