1、在jdbc.properties中
username=(自己的mysql用户名)
password=(自己的mysql密码)
url=jdbc:mysql://localhost:3306/book?characterEncoding=utf8&useSSL=false
driverClassName=com.mysql.jdbc.Driver
initialSize=5
maxActive=1
MySQL 8.0 以上版本不需要建立 SSL 连接的,需要显式关闭。
MySQL 5.7 之前版本,安全性做的并不够好,比如安装时生成的root空密码账号、存在任何用户都能连接上的 test 库等,导致数据库存在较大的安全隐患。从5.7版本开始MySQL官方对这些问题逐步进行了修复,到了 MySQL 8.0 以上版本已经不需要使用 SSL 进行连接加密了。但是高版本仍然保留了这个接口,所以需要在连接的时候手动写明是否需要进行 SSL 连接,这里我们手动关闭 SSL 连接加密就OK。
useSSL=false
2、C:\Windows\system32>mysql -u root -p
Enter password: ****
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
解决方法:
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysqld --install
切换到mysql安装目录下的bin文件夹,命令行运行"mysqld --install"
此时使用“net start mysql”成功启动msyql,一般就可以正常启动mysql了
C:\Program Files\MySQL\MySQL Server 8.0\bin>net start mysql
MYSQL 服务正在启动 ..
MYSQL 服务已经启动成功。
C:\Program Files\MySQL\MySQL Server 8.0\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.18 MySQL Community Server - GPL
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无法正常启动
可以去计算机管理里面查看mysql是否已经开启