资源
个人笔记
常见问题汇总
Windows 打开/关闭 MySQL
以管理员身份运行cmd命令提示符:
打开
net start mysql
关闭
net stop mysql
登录
mysql -u root -p
忘记 MySQL 密码
Windows 更改 MySQL 密码
- 首先停止正在运行的 MySQL 进程,以管理员身份运行 cmd,输入:
C:\Windows\system32>net stop mysql MySQL 服务正在停止.. MySQL 服务已成功停止。
- 进入 MySQL 安装目录, 以安全模式启动 MySQL:
E:\mysql-5.7.15-winx64\mysql-5.7.15-winx64\bin>mysqld.exe --skip-grant-tables
- 然后就可以免密码登录 MySQL,提示输入密码时直接按 Enter:
```
E:\mysql-5.7.15-winx64\mysql-5.7.15-winx64\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.15 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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>
4. 更改密码:
mysql> use mysql
Database changed
mysql> update MySQL.user set authentication_string=password(‘tjkcht’) where User=’root’;
Query OK, 1 row affected, 1 warning (0.08 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
5. 重启 MySQL 服务,在任务管理器里关闭所有MySQL的进程,使用下面的命令启动:
E:\mysql-5.7.15-winx64\mysql-5.7.15-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
## MySQL Workbench “Error Code: 1175”
1. 在 Workbench 中,打开 **Edit->Preferences->SQL Editer**,取消勾选["Safe Update".Forbid UPDATEs and DELETEs with no key in WHERE clause or no LIMIT clause. Requires a reconnection.]。
2. 断开后重新连接数据库。
## MySQL JDBC 插入中文异常
修改 JDBC 的链接,添加**"useUnicode=true&characterEncoding=UTF-8**:
jdbc:mysql://localhost/parking_test?” +
“user=root&password=tjkcht” +
“&useUnicode=true&characterEncoding=UTF-8”);