我想很多朋友都有碰到过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 自动停止的问题.
另外一种情况:
- 10090422:37:27InnoDB:Logfile.ib_logfile0didnotexist:newtobecreated
- InnoDB:Settinglogfile.ib_logfile0sizeto10MB
- InnoDB:Databasephysicallywritesthefilefull:wait...
- 10090422:37:28InnoDB:Logfile.ib_logfile1didnotexist:newtobecreated
- InnoDB:Settinglogfile.ib_logfile1sizeto10MB
- InnoDB:Databasephysicallywritesthefilefull:wait...
- InnoDB:Doublewritebuffernotfound:creatingnew
- InnoDB:Doublewritebuffercreated
- InnoDB:Creatingforeignkeyconstraintsystemtables
- InnoDB:Foreignkeyconstraintsystemtablescreated
- 10090422:37:29InnoDB:Started;logsequencenumber00
- 10090422:37:29[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 10090422:37:29[ERROR]Aborting
- 10090422:37:29InnoDB:Startingshutdown...
- 10090422:37:31InnoDB:Shutdowncompleted;logsequencenumber043655
- 10090422:37:31[Note]wampmysqld:Shutdowncomplete
- 10090422:43:42InnoDB:Started;logsequencenumber043655
- 10090422:43:42[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 10090422:43:42[ERROR]Aborting
- 10090422:43:42InnoDB:Startingshutdown...
- 10090422:43:45InnoDB:Shutdowncompleted;logsequencenumber043655
- 10090422:43:45[Note]wampmysqld:Shutdowncomplete
- 10090422:43:49InnoDB:Started;logsequencenumber043655
- 10090422:43:49[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 10090422:43:49[ERROR]Aborting
- 10090422:43:49InnoDB:Startingshutdown...
- 10090422:43:52InnoDB:Shutdowncompleted;logsequencenumber043655
- 10090422:43:52[Note]wampmysqld:Shutdowncomplete
- 1009058:23:24InnoDB:Started;logsequencenumber043655
- 1009058:23:24[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009058:23:24[ERROR]Aborting
- 1009058:23:24InnoDB:Startingshutdown...
- 1009058:23:27InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009058:23:27[Note]wampmysqld:Shutdowncomplete
- 1009058:23:28InnoDB:Started;logsequencenumber043655
- 1009058:23:28[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009058:23:28[ERROR]Aborting
- 1009058:23:28InnoDB:Startingshutdown...
- 1009058:23:30InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009058:23:30[Note]wampmysqld:Shutdowncomplete
- 1009058:41:35InnoDB:Started;logsequencenumber043655
- 1009058:41:35[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009058:41:35[ERROR]Aborting
- 1009058:41:35InnoDB:Startingshutdown...
- 1009058:41:37InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009058:41:37[Note]wampmysqld:Shutdowncomplete
- 1009058:41:42InnoDB:Started;logsequencenumber043655
- 1009058:41:42[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009058:41:42[ERROR]Aborting
- 1009058:41:42InnoDB:Startingshutdown...
- 1009058:41:45InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009058:41:45[Note]wampmysqld:Shutdowncomplete
- 1009058:47:15InnoDB:Started;logsequencenumber043655
- 1009058:47:15[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009058:47:15[ERROR]Aborting
- 1009058:47:15InnoDB:Startingshutdown...
- 1009058:47:17InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009058:47:17[Note]wampmysqld:Shutdowncomplete
- 1009058:54:20InnoDB:Started;logsequencenumber043655
- 1009058:54:20[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009058:54:20[ERROR]Aborting
- 1009058:54:20InnoDB:Startingshutdown...
- 1009058:54:23InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009058:54:23[Note]wampmysqld:Shutdowncomplete
- 1009058:54:53InnoDB:Started;logsequencenumber043655
- 1009058:54:53[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009058:54:53[ERROR]Aborting
- 1009058:54:53InnoDB:Startingshutdown...
- 1009058:54:55InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009058:54:55[Note]wampmysqld:Shutdowncomplete
- 1009058:58:20InnoDB:Started;logsequencenumber043655
- 1009058:58:20[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009058:58:20[ERROR]Aborting
- 1009058:58:20InnoDB:Startingshutdown...
- 1009058:58:22InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009058:58:22[Note]wampmysqld:Shutdowncomplete
- 1009058:59:57InnoDB:Started;logsequencenumber043655
- 1009058:59:57[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009058:59:57[ERROR]Aborting
- 1009058:59:57InnoDB:Startingshutdown...
- 1009059:00:00InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009059:00:00[Note]wampmysqld:Shutdowncomplete
- 1009059:02:21InnoDB:Started;logsequencenumber043655
- 1009059:02:21[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009059:02:21[ERROR]Aborting
- 1009059:02:21InnoDB:Startingshutdown...
- 1009059:02:23InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009059:02:23[Note]wampmysqld:Shutdowncomplete
- 1009059:02:29InnoDB:Started;logsequencenumber043655
- 1009059:02:29[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009059:02:29[ERROR]Aborting
- 1009059:02:29InnoDB:Startingshutdown...
- 1009059:02:31InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009059:02:31[Note]wampmysqld:Shutdowncomplete
- 1009059:08:16InnoDB:Started;logsequencenumber043655
- 1009059:08:16[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009059:08:16[ERROR]Aborting
- 1009059:08:16InnoDB:Startingshutdown...
- 1009059:08:18InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009059:08:18[Note]wampmysqld:Shutdowncomplete
- 1009059:08:54InnoDB:Started;logsequencenumber043655
- 1009059:08:54[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009059:08:54[ERROR]Aborting
- 1009059:08:54InnoDB:Startingshutdown...
- 1009059:08:56InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009059:08:56[Note]wampmysqld:Shutdowncomplete
- 1009059:35:05InnoDB:Started;logsequencenumber043655
- 1009059:35:05[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009059:35:05[ERROR]Aborting
- 1009059:35:05InnoDB:Startingshutdown...
- 1009059:35:08InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009059:35:08[Note]wampmysqld:Shutdowncomplete
- 1009059:38:08InnoDB:Started;logsequencenumber043655
- 1009059:38:08[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 1009059:38:08[ERROR]Aborting
- 1009059:38:08InnoDB:Startingshutdown...
- 1009059:38:10InnoDB:Shutdowncompleted;logsequencenumber043655
- 1009059:38:10[Note]wampmysqld:Shutdowncomplete
- 10090516:18:51InnoDB:Started;logsequencenumber043655
- 10090516:18:52[ERROR]Doyoualreadyhaveanothermysqldserverrunningonport:3306?
- 10090516:18:52[ERROR]Aborting
- --phpfensi.com
- 10090516:18:52InnoDB:Startingshutdown...
- 10090516:18:54InnoDB:Shutdowncompleted;logsequencenumber043655
- 10090516:18:54[Note]wampmysqld:Shutdowncomplete
经过分析是:3306端口被占用了.
1.以前安装的mysql没有卸载干净
2.其他程序(如迅雷随机获取端口号)占用了3306端口
这样就好办了,只要在mysql配置文件把端口修改一下就可以了.