Mysql的zip包安装
1.下载mysql的zip包并解压
2.进入目录新建my.ini文件,复制下面信息,并修改文件目录地址
[mysqld]
port=3306
# 设置mysql的安装目录
basedir=D:\app\mysql-8.0.16-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\app\mysql-8.0.16-winx64\Data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8
3.初始化mysql 并打印信息,命令行进入bin目录 执行mysqld --initialize --console 得到mysql的用户密码
D:\app\mysql-8.0.16-winx64\bin>mysqld --initialize --console
2019-07-02T02:46:43.939592Z 0 [System] [MY-013169] [Server] D:\app\mysql-8.0.16-
winx64\bin\mysqld.exe (mysqld 8.0.16) initializing of server in progress as proc
ess 5280
2019-07-02T02:46:50.236403Z 5 [Note] [MY-010454] [Server] A temporary password i
s generated for root@localhost: pa=z90sp%pW(
2019-07-02T02:46:52.800610Z 0 [System] [MY-013170] [Server] D:\app\mysql-8.0.16-
winx64\bin\mysqld.exe (mysqld 8.0.16) initializing of server has completed
//由上可知此次初始化的密码是 pa=z90sp%pW(
4.以管理员身份重新打开一个dos命令行进入mysql的bin目录执行mysqld install [服务名],服务名默认为mysql
C:\Users\Administrator>d:
D:\>cd app
D:\app>cd mysql-8.0.16-winx64
D:\app\mysql-8.0.16-winx64>cd bin
D:\app\mysql-8.0.16-winx64\bin>mysqld install mysql
Service successfully installed.
D:\app\mysql-8.0.16-winx64\bin>
5.确保mysql服务启动,启动命令为net start mysql启动服务,其中mysql就是服务名
6.输入命令mysql -u root -p开始修改密码
D:\app\mysql-8.0.16-winx64\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.16
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
//修改密码 最后的冒号一定要打
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1
23456';
Query OK, 0 rows affected (0.01 sec)
7.使用命令行net stop mysql停止服务 完成安装
8.使用springboot 连接配置信息
jdbc:mysql://localhost:3306/song?useUnicode=true&characterEncoding=UTF-8&useSSL=false