mySql 安装创建 与IDEA连接数据库

231 阅读1分钟

IDEA安装配置:

从头搭建 IntelliJ IDEA 环境

安装: 

MySQL 安装 | 菜鸟教程 (runoob.com)

修改密码:

 MySQL 5.7.17 下:

 set password for root@localhost =password(‘新密码’);   

 MySQL 8.0.27 :

 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';

创建数据库

 create database firstdb

创建用户

create user 'fengjingchao'@'localhost' identified by 'a123456z';

分配权限:

grant all privileges on firstdb.* to 'fengjingchao'@'localhost' with grant option;

刷新权限:

flush privileges;

CREATE TABLE IF NOT EXISTS `Xuser`(
`xuser_id` INT UNSIGNED AUTO_INCREMENT,
`xuser_age` INT UNSIGNED,
`xuser_name` VARCHAR(40) NOT NULL,
PRIMARY KEY (`xuser_id`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;

 CREATE TABLE IF NOT EXISTS `Xuser`(`xuser_id` INT UNSIGNED AUTO_INCREMENT,`xuser_age` INT UNSIGNED,`xuser_name` VARCHAR(40) NOT NULL,PRIMARY KEY (`xuser_id`))ENGINE=InnoDB DEFAULT CHARSET=utf8; 

IDEA关联数据库

IDEA配置修改:

application.yml

spring:
  datasource:
    //添加时区serverTimezone=Asia/Shanghai    url: jdbc:mysql://localhost:3306/firstdb?characterEncoding=utf8&serverTimezone=Asia/Shanghai
    username: fengjingchao
    password: a123456z
    driver-class-name: com.mysql.cj.jdbc.Driver //新的Driver
    
mybatis:
  mapper-locations: classpath:mapper/*.xml
    

连接mysql出现“Unable to load authentication plugin 'caching_sha2_password”错误

pom.xml 修改版本8.0.11