mysql 问题总结

1.mysql8.0忘记密码或出现Access denied for user 'root'@'localhost' (using password: YES)

1、找到mysql安装路径

(可以在环境变量中找)

2、以管理员身份打开命令行,停止服务

(win+q输入cmd右击)

(net stop mysql)

3、cd 到mysql安装路径的bin目录,之前版本输入mysqld --skip-grant-tables,8.0输入mysqld --console --skip-grant-tables --shared-memory

4、打开另一个管理员命令行,cd 到mysql安装路径的bin目录,输入mysql,输入use mysql

5、flush privileges;

6、使用alter user'root'@'localhost' IDENTIFIED BY 'Li!123456'; 修改密码

(8.0以后版本密码必须包含大小写字母特殊字符和数字)

7、 flush privileges;  (重要)

8、\q退出

9、重新以管理员打开命令行,net start mysql

10、登陆 mysql -u root -p

2.The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized

原文:JDBC连接mysql出现时区错误:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized...处理方法_蘅时天下的博客-CSDN博客

方法一:
首先打开cmd登录mysql后输入select curtime();或select now();查看当前时间
在这里插入图片描述
然后查看当前时区(show variables like “%time_zone%”)
在这里插入图片描述
system_time_zone 为空表示当前mysql时间与系统一致,time_zone为SYSTEM表示当前使用的时区为SYSTEM时区

最后将时区更改为现在所在时区(东八区)
<1>set time_zone="+8:00"; 只能修改当前会话窗口的时区,关闭即还原
在这里插入图片描述
<2>set global time_zone="+8:00"; 修改全局时区,永久有效
在这里插入图片描述

3 logstash使用过程中,虚拟机(linux)连主机(win10)mysql(8.0.22)连不通的问题(本来以为是logstash版本和mysql connector版本的问题,走了半天弯路。。。)

Could not create connection to database server. Attempted reconnect 3 times. Giving up

到主机mysql bin目录下

mysql -uroot -p123456 登录mysql

use mysql;

grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;(mysql8.0不适用)

https://www.cnblogs.com/Loners/p/12348366.html

MySQL 8.0已经不支持下面这种命令写法
grant all privileges on *.* to root@"%" identified by ".";

正确的写法是先创建用户
CREATE USER 'root'@'%' IDENTIFIED BY 'Hadoop3!';
再给用户授权
grant all privileges on *.* to 'root'@'%' ;

4. javax.net.ssl.SSLException MESSAGE: closing inbound before receiving peer's close_notify

配置连接数据库的url时,加上useSSL=false

jdbc:mysql://localhost:3306/tablename?useUnicode=true&characterEncoding=UTF-8&autoReconnect=FALSE&serverTimezone=GMT&useSSL=false

javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify的解决办法_进击的大猪的博客-CSDN博客

5. Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) - Stack Overflow
Are you connecting to "localhost" or "127.0.0.1" ? I noticed that when you connect to "localhost" the socket connector is used, but when you connect to "127.0.0.1" the TCP/IP connector is used. You could try using "127.0.0.1" if the socket connector is not enabled/working.

localhost换成127.0.0.1,还真有用

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值