今天公司很久以前的一台WDCP集成的Web服务出现了问题,打开网页显示“无法连接mysql,请检查mysql是否已启动及用户密码是否配置正确”

    

                 (上图为服务器故障时Web访问报错信息)

    

    在网上找了三个小时的资料,找到了很多遇到该问题的朋友,并且只要是数据库连接不正常的或者数据库无法正常启动的,全都会报这个错误,下面是我的解决方法:


1、检查服务运行状态

[root@WDCP etc]# service mysqld status

 mysql is not running.

#mysql服务并未运行


[root@WDCP etc]# service mysqld restart

 ERROR! MySQL manager or server PID file could not be found!

Starting MySQL. ERROR! Manager of pid-file quit without updating file.

#试图重启服务,结果报错


[root@WDCP etc]# cat /www/wdlinux/mysql-5.1.69/var/WDCP.err

查看WDCP的错误日志


    171209 16:10:02 mysqld_safe mysqld from pid file /www/wdlinux/mysql-5.1.69/var/WDCP.pid ended

    171209 16:12:25 mysqld_safe Starting mysqld daemon with databases from /www/wdlinux/mysql-5.1.69/var

    171209 16:12:25 [ERROR] /www/wdlinux/mysql-5.1.69/libexec/mysqld: unknown variable 'innodb_additional_mem_pool_size=16M'

    171209 16:12:25 [ERROR] Aborting

    #从日志看为止的innodb我觉定把innodb的选项注释掉看一下,结果重启服务报了一个新的错误。


    171209 16:10:02 mysqld_safe mysqld from pid file /www/wdlinux/mysql-5.1.69/var/WDCP.pid ended

    171209 16:12:25 mysqld_safe Starting mysqld daemon with databases from /www/wdlinux/mysql-5.1.69/var

    171209 16:12:25 [ERROR] /www/wdlinux/mysql-5.1.69/libexec/mysqld: unknown variable 'innodb_additional_mem_pool_size=16M'

    171209 16:12:25 [ERROR] Aborting

    

    171209 16:12:25 [Note] /www/wdlinux/mysql-5.1.69/libexec/mysqld: Shutdown complete

    

    171209 16:12:25 mysqld_safe mysqld from pid file /www/wdlinux/mysql-5.1.69/var/WDCP.pid ended

    171209 16:13:32 mysqld_safe Starting mysqld daemon with databases from /www/wdlinux/mysql-5.1.69/var

    171209 16:13:32 [ERROR] /www/wdlinux/mysql-5.1.69/libexec/mysqld: unknown variable 'innodb_buffer_pool_size=2G'

    171209 16:13:32 [ERROR] Aborting

    #还是和innodb有关系,决定吧所有的innodb都注销掉!!!    


    171209 16:13:32 [Note] /www/wdlinux/mysql-5.1.69/libexec/mysqld: Shutdown complete

    

    171209 16:13:32 mysqld_safe mysqld from pid file /www/wdlinux/mysql-5.1.69/var/WDCP.pid ended

    171209 16:14:34 mysqld_safe Starting mysqld daemon with databases from /www/wdlinux/mysql-5.1.69/var

    171209 16:14:35 [ERROR] /www/wdlinux/mysql-5.1.69/libexec/mysqld: unknown variable 'innodb_buffer_pool_size=2G'

    171209 16:14:35 [ERROR] Aborting

    

    171209 16:14:35 [Note] /www/wdlinux/mysql-5.1.69/libexec/mysqld: Shutdown complete

    

    171209 16:14:35 mysqld_safe mysqld from pid file /www/wdlinux/mysql-5.1.69/var/WDCP.pid ended


    #在/www/wdlinux/etc/my.cnf有关innodb的选项全部注释掉

    #innodb_buffer_pool_size = 2G

    #innodb_data_file_path = ibdata1:10M:autoextend

    #innodb_file_io_threads = 4

    #innodb_thread_concurrency = 16

    #innodb_flush_log_at_trx_commit = 1

    #innodb_log_buffer_size = 8M

    #innodb_log_file_size = 256M

    #innodb_log_files_in_group = 3

    #innodb_max_dirty_pages_pct = 90

    #innodb_lock_wait_timeout = 120


    启动mysql服务进行测试:

    

    [root@WDCP ~]# service mysqld start

    Starting MySQL. SUCCESS!

    #mysql启动成功


    具体原因暂时还没找到,主要是因为这不是主要的业务系统,以及该系统是前期开发人员搭建的,所以存在一些问题,此文档仅作为简单记录,查出具体问题后会整理详细文档。