Skip to content

Commit 99adafa

Browse files
committed
添加MySQL启动报错处理方法
1 parent 1584ad4 commit 99adafa

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

chapter2/2.3.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,48 @@ net stop mysql
131131
### Windows 下操作
132132
133133
Windows 系统下启动关闭重启MySQL服务。
134+
135+
## 启动报错
136+
137+
下面是我尝试在Mac上启动MySQL报错
138+
139+
**启动失败**
140+
141+
```bash
142+
sudo /usr/local/mysql/support-files/mysql.server start
143+
Password:
144+
Starting MySQL
145+
. ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.pid
146+
```
147+
148+
通过日志查看报错信息
149+
150+
```bash
151+
# 编辑配置文件
152+
sudo vim /etc/my.cnf
153+
154+
# 在配置文件最后添加一行错误日志输入的配置
155+
log_error = /usr/local/mysql/data/error.log
156+
```
157+
158+
上面添加完成之后,重新启动再查看日志
159+
160+
```bash
161+
sudo /usr/local/mysql/support-files/mysql.server start
162+
tail -100 /usr/local/mysql/data/error.log
163+
```
164+
165+
日志显示
166+
167+
```bash
168+
2017-01-19T03:48:24.695505Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 35
169+
2017-01-19T03:48:24.695540Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
170+
```
171+
172+
日志显示 mysqld 进程使用相同的InnoDB data 文件或日志文件,通过 `ps -ef | grep mysql | grep -v grep` 查看是否有该进程,发现果然有,这时候你需要杀掉该进程,我在我本地是杀不掉的,于是我尝试使用 mysqld 启动MySQL,启动成功。
173+
174+
```bash
175+
sudo /usr/local/mysql/bin/mysqld restart
176+
```
177+
178+
上面调试定位错误的方法非常有用。我通过这个方法多次解决各种问题。

0 commit comments

Comments
 (0)