我想很多朋友都有碰到过mysql服务器突然自动停止或又会自动启动吧,下面我们来分析一下原因与停止的解决办法.
分析原因一:Mysql的自动备份功能可能导致数据库在备份的时候先关闭服务,而在此启动的时候服务器不响应,开始-运行-services.msc,打开windows服务找到mysql的服务并双击,点击恢复选项卡,第一次失败:默认是“不操作”,改成”重新启动服务”。
在下方的“重新启动服务:分钟后”添上“0”表示如果服务意外终止则立即重启动。点击确定使设置生效。这时候你在任务管理器里结束mysql-nt进程,会发现结束不掉,不过要注意,这样mysql.exe是停不了的,如果要停必须把刚才修改的改回来.)
分析原因二:可能是mysql连接问题
修改mysql的最大连接数, 使用内存变量修改法修改mysql的最大连接数
步骤如下,同时适用windows和linux平台:
a、客户端登录mysql,输入用户名和密码’
b、在mysql命令提示符下设置新的最大连接数为500:mysql> set global max_connections=500
c、显示当前运行的query:mysql> show processlist
d、显示当前mysql 系统参数状态:mysql> show status# k;
e、退出客户端:mysql> exit’
查看当前最大连接数只需要通过在mysqladmin所在目录下执行以下命令:mysqladmin -username -password variables |find “max_con” 即可看到。也可以使用php教程myadmin里头的mysql参数列表查看最大连接数。
缺点:重启计算机或者mysql后最大连接数又会复位成初始值,需要重新设定。
修改my.ini或my.cnf文件法(需要重启mysql),可参考同目录下mysql的配置模板(小内存、大内存、超大内存) . e windows系统下打开my.ini文件找到set-variable =max_connections=100这一行,改成需要设定的最大连接数,然后重启即可。
linux控制台下:
1、打开my.cnf文件:vi /etc/my.cnf
2 在[mysqld]段下修改max_connections的值为设定值。
注意:可能大家安装的mysql来源和版本不同,windows下mysql+iis和php+apache+mysql套件最终安装结果几乎都不相同,my.ini文件的路径可能有些不同,my.ini可能还会保留一份在c:windows目录下需要同时修改,这个方法是我在无意中发现的,经测试是可行的,下面拿出来和大家分享.
我的电脑 -> 右击 -> 服务 -> 找到 mysql服务 双击 新窗口中 -> 恢复 -> 第一次失败 设置为 重新启动服务.
下面重置失败计数 设置为0 重新启动服务 设置为0,就这样,就轻松搞定了mysql 自动停止的问题.
另外一种情况:
- 100904 22:37:27 InnoDB: Log file .ib_logfile0 did not exist: new to be created
- InnoDB: Setting log file .ib_logfile0 size to 10 MB
- InnoDB: Database physically writes the file full: wait...
- 100904 22:37:28 InnoDB: Log file .ib_logfile1 did not exist: new to be created
- InnoDB: Setting log file .ib_logfile1 size to 10 MB
- InnoDB: Database physically writes the file full: wait...
- InnoDB: Doublewrite buffer not found: creating new
- InnoDB: Doublewrite buffer created
- InnoDB: Creating foreign key constraint system tables
- InnoDB: Foreign key constraint system tables created
- 100904 22:37:29 InnoDB: Started; log sequence number 0 0
- 100904 22:37:29 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100904 22:37:29 [ERROR] Aborting
-
- 100904 22:37:29 InnoDB: Starting shutdown...
- 100904 22:37:31 InnoDB: Shutdown completed; log sequence number 0 43655
- 100904 22:37:31 [Note] wampmysqld: Shutdown complete
-
- 100904 22:43:42 InnoDB: Started; log sequence number 0 43655
- 100904 22:43:42 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100904 22:43:42 [ERROR] Aborting
-
- 100904 22:43:42 InnoDB: Starting shutdown...
- 100904 22:43:45 InnoDB: Shutdown completed; log sequence number 0 43655
- 100904 22:43:45 [Note] wampmysqld: Shutdown complete
-
- 100904 22:43:49 InnoDB: Started; log sequence number 0 43655
- 100904 22:43:49 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100904 22:43:49 [ERROR] Aborting
-
- 100904 22:43:49 InnoDB: Starting shutdown...
- 100904 22:43:52 InnoDB: Shutdown completed; log sequence number 0 43655
- 100904 22:43:52 [Note] wampmysqld: Shutdown complete
-
- 100905 8:23:24 InnoDB: Started; log sequence number 0 43655
- 100905 8:23:24 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 8:23:24 [ERROR] Aborting
-
- 100905 8:23:24 InnoDB: Starting shutdown...
- 100905 8:23:27 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 8:23:27 [Note] wampmysqld: Shutdown complete
-
- 100905 8:23:28 InnoDB: Started; log sequence number 0 43655
- 100905 8:23:28 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 8:23:28 [ERROR] Aborting
-
- 100905 8:23:28 InnoDB: Starting shutdown...
- 100905 8:23:30 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 8:23:30 [Note] wampmysqld: Shutdown complete
-
- 100905 8:41:35 InnoDB: Started; log sequence number 0 43655
- 100905 8:41:35 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 8:41:35 [ERROR] Aborting
-
- 100905 8:41:35 InnoDB: Starting shutdown...
- 100905 8:41:37 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 8:41:37 [Note] wampmysqld: Shutdown complete
-
- 100905 8:41:42 InnoDB: Started; log sequence number 0 43655
- 100905 8:41:42 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 8:41:42 [ERROR] Aborting
-
- 100905 8:41:42 InnoDB: Starting shutdown...
- 100905 8:41:45 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 8:41:45 [Note] wampmysqld: Shutdown complete
-
- 100905 8:47:15 InnoDB: Started; log sequence number 0 43655
- 100905 8:47:15 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 8:47:15 [ERROR] Aborting
-
- 100905 8:47:15 InnoDB: Starting shutdown...
- 100905 8:47:17 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 8:47:17 [Note] wampmysqld: Shutdown complete
-
- 100905 8:54:20 InnoDB: Started; log sequence number 0 43655
- 100905 8:54:20 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 8:54:20 [ERROR] Aborting
-
- 100905 8:54:20 InnoDB: Starting shutdown...
- 100905 8:54:23 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 8:54:23 [Note] wampmysqld: Shutdown complete
-
- 100905 8:54:53 InnoDB: Started; log sequence number 0 43655
- 100905 8:54:53 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 8:54:53 [ERROR] Aborting
-
- 100905 8:54:53 InnoDB: Starting shutdown...
- 100905 8:54:55 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 8:54:55 [Note] wampmysqld: Shutdown complete
-
- 100905 8:58:20 InnoDB: Started; log sequence number 0 43655
- 100905 8:58:20 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 8:58:20 [ERROR] Aborting
-
- 100905 8:58:20 InnoDB: Starting shutdown...
- 100905 8:58:22 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 8:58:22 [Note] wampmysqld: Shutdown complete
-
- 100905 8:59:57 InnoDB: Started; log sequence number 0 43655
- 100905 8:59:57 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 8:59:57 [ERROR] Aborting
-
- 100905 8:59:57 InnoDB: Starting shutdown...
- 100905 9:00:00 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 9:00:00 [Note] wampmysqld: Shutdown complete
-
- 100905 9:02:21 InnoDB: Started; log sequence number 0 43655
- 100905 9:02:21 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 9:02:21 [ERROR] Aborting
-
- 100905 9:02:21 InnoDB: Starting shutdown...
- 100905 9:02:23 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 9:02:23 [Note] wampmysqld: Shutdown complete
-
- 100905 9:02:29 InnoDB: Started; log sequence number 0 43655
- 100905 9:02:29 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 9:02:29 [ERROR] Aborting
-
- 100905 9:02:29 InnoDB: Starting shutdown...
- 100905 9:02:31 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 9:02:31 [Note] wampmysqld: Shutdown complete
-
- 100905 9:08:16 InnoDB: Started; log sequence number 0 43655
- 100905 9:08:16 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 9:08:16 [ERROR] Aborting
-
- 100905 9:08:16 InnoDB: Starting shutdown...
- 100905 9:08:18 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 9:08:18 [Note] wampmysqld: Shutdown complete
-
- 100905 9:08:54 InnoDB: Started; log sequence number 0 43655
- 100905 9:08:54 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 9:08:54 [ERROR] Aborting
-
- 100905 9:08:54 InnoDB: Starting shutdown...
- 100905 9:08:56 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 9:08:56 [Note] wampmysqld: Shutdown complete
-
- 100905 9:35:05 InnoDB: Started; log sequence number 0 43655
- 100905 9:35:05 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 9:35:05 [ERROR] Aborting
-
- 100905 9:35:05 InnoDB: Starting shutdown...
- 100905 9:35:08 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 9:35:08 [Note] wampmysqld: Shutdown complete
-
- 100905 9:38:08 InnoDB: Started; log sequence number 0 43655
- 100905 9:38:08 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 9:38:08 [ERROR] Aborting
-
- 100905 9:38:08 InnoDB: Starting shutdown...
- 100905 9:38:10 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 9:38:10 [Note] wampmysqld: Shutdown complete
-
- 100905 16:18:51 InnoDB: Started; log sequence number 0 43655
- 100905 16:18:52 [ERROR] Do you already have another mysqld server running on port: 3306 ?
- 100905 16:18:52 [ERROR] Aborting
-
- 100905 16:18:52 InnoDB: Starting shutdown...
- 100905 16:18:54 InnoDB: Shutdown completed; log sequence number 0 43655
- 100905 16:18:54 [Note] wampmysqld: Shutdown complete
经过分析是:3306端口被占用了.
1.以前安装的mysql没有卸载干净
2.其他程序(如迅雷随机获取端口号)占用了3306端口
这样就好办了,只要在mysql配置文件把端口修改一下就可以了. |