发现没有my.cnf可以自己创建,并放在/etc中
1 user=mysql 2 character_set_server = utf8 3 basedir=/usr/local/mysql 4 datadir=/usr/local/mysql/data 5 pid-file=/usr/local/mysql/data/iz2ze2t0ob6ppkgpmww0unz.pid 6 log-error=iz2ze2t0ob6ppkgpmww0unz.err
1).root无法登陆
原因:mysql8使用新的加密规则caching_sha2_password (之前使用的是mysql_native_password) 同事废弃了密码字段password改用authentication_string
解决:启动时跳过验证: ./mysqld_safe --skip-grant-tables &(不是后台程序) ,然后回车后登陆root(无密码) ,置空root的authentication_string字段,再修改密码
1 update user set authentication_string='' where user='root'; 2 3 ALTER user 'root'@'localhost' IDENTIFIED BY 'Admin123#'; 4 5 (修改密码时,不要用update,因为authentication_string字段下只能是mysql加密后的41位字符串密码) 6 7 (或者在my.cnf中加入skip-grant-tables登陆root)
2)客服端远程连接错误: authentication plugin 'caching_sha2_password'
原因:mysql8新的加密规则
解决:第一种 修改配置文件my.cnf 加入
default_authentication_plugin=mysql_native_password第二种专门创建一个以前版本的规则的账号,用于远程连接(官方推荐)
1 create user 'your username'@'%' identified with mysql_native_password by 'pwd' 2 3 grant all privileges on *.* to yourUsername@'%' with grant option; 4 5 flush privileges备注:select host, user, authentication_string, plugin from user; // 查看系统user表信息
3)删除用户之后,重新创建失败
delete之后,flush privileges。不行的话,重新drop一遍,再flush privileges
另:新的连接url方式参考:
// 驱动包升级: mysql-connector-java-8.0.11.jar// JDBC driver 由“com.mysql.jdbc.Driver”改为“com.mysql.cj.jdbc.Driver” jdbc.url=jdbc:mysql://127.0.0.1:3306?characterEncoding=utf8&useUnicode=true&useSSL=false&serverTimezone=UTC
转载于:https://www.cnblogs.com/laoyin666/p/9278645.html
相关资源:JAVA上百实例源码以及开源项目