第一步:IDEA配置数据库连接
第二步:IDEA配置数据库连接
用户名和密码为上面mysql数据库已经创建的用户名和密码。url指的是数据库服务器的地址,当输入数据库时,name以及url都会自动添加mysql,“localhost”指的是用户地址
第三步:点击 Test connection,并且会弹出一个框,提示下载驱动,点击进行下载即可
第四步:创建数据库与表格
create database band2 default collate utf8-bin;
use band2;
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `band`
-- ----------------------------
DROP TABLE IF EXISTS `band`;
CREATE TABLE `band` (
`id` int(11) NOT NULL,
`name` varchar(20) NOT NULL,
`remark` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of band
-- ----------------------------
-- ----------------------------
-- Table structure for `student`
-- ----------------------------
DROP TABLE IF EXISTS `student`;
CREATE TABLE `student` (
`id` varchar(10) NOT NULL,
`name` varchar(20) NOT NULL,
`band_id` int(11) NOT NULL,
`create_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`address` varchar(100) default NULL,
`status` tinyint(4) NOT NULL default '9',
PRIMARY KEY (`id`),
KEY `band_id` (`band_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of student
-- ----------------------------
第五步:建表成功
在workbench上可查看连接成功