安装背景:
- Window10安装MySQL-Server与NavicatPremium可视化工具交互
- 宿主机(Win10)想跟VM虚拟机下的Ubuntu交互,本地数据库备份
Bug1简介: mysql5.7安装后,会自动启动服务,在这个时候输入net start mysql 会出现服务名无效的问题.
解决方案:
- 方案一:进入C:/Window/System32/cmd.exe 右键以管理员身份运行 ,cd到mysql安装目录bin下 输入命令 mysqld –initialize,初始化后mysql才有data文件夹。
- 方案二:右键win10左下角图标,选择以管理员身份打开Window PowerShell,输入mysqld.exe -install
经过上述操作就会在MySQL安装目录下出现data文件
Bug2简介:在生成data文件之后出现的情况Mysql ERROR 1045 (28000) Access denied for user 'root'@'localhost'
Mysql ERROR 1045 (28000) Access denied for user 'root'localhost'的原因.png解决方案:
- 关闭mysql服务 net stop mysql
- cd 到D:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld -nt --skip -grant -tables 以管理员身份运行这段命令,相当于在my.ini中[mysqld]下加入skip-grant-tables,就可以跳过登录校验,此时命令窗口不会动啦,
- 重开一个窗口 ,
- 直接登录 mysql -u root -p (前提:mysql加入环境变量)
- mysql> use mysql
- 这是5.7以后更新账户密码的新语句,5.7以后password字段不在存在,会报如下错误:ERROR 1054 (42S22): Unknown column 'password' in 'field list'
- PS: update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
3.0 C:\Users\hp>net start mysql 发生系统错误 5。 拒绝访问。
cmd程序没有够高的执行权限造成的系统错误.png以管理员身份运行cmd.exe 然后net start mysql
管理员身份下的命令运行结果.pngMySQL字符编码问题
[Err] 1366 - Incorrect string value: '\xE7\x94\xB5\xE8\xA7\x86...' for column 'sName' at row 1
方法一:在当前窗口设置数据库编码格式为gbk,set
character_set_results=gbk;
方法二:在mysql安装目录下有my.ini文件
default-character-set=gbk 客户端编码设置
character-set-server=utf8 服务器端编码设置
方法三:在创建表而定时候指定默认字符编码格式为utf8,default charset=utf8
新版本mysql-connector-java-8.0.11 jdbc驱动安全限制
报错一:Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
报错二:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utili
String url = "jdbc:mysql://localhost:3306/mydb?useSSL=false&serverTimezone=UTC";
String user = "root";
String password = "123456";
Connection conn = DriverManager.getConnection(url, user, password);
网友评论