消息:mysqli :: real_connect():( HY000 / 2002)

时间:2018-05-29 12:51:09

标签: php mysql codeigniter mysqli

您好我的codeigniter应用程序,当我尝试连接我的MySql数据库时发生以下错误

  

消息:mysqli :: real_connect():( HY000 / 2002):连接尝试   失败,因为关联方在a之后没有正确回应   一段时间,或建立的连接失败,因为连接   主持人没有回复。

我正在使用Windows 10系统

XAMPP v3.2.2

PHP Version 7.2.4

Phpmyadmin 4.8.1

Codeigniter配置设置

'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '',
    'database' => 'XXXXXX',
    'dbdriver' => 'mysqli',
    'dbprefix' => 'ss_',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'development'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE

有些人建议将主机名更改为127.0.0.1,但这对我不起作用,其中一些建议编辑System32 \ drivers \ etc \ host设置但我没有得到任何正面结果,这里有我也附上主机设置

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

对不起我的英文,并提前谢谢你:)

0 个答案:

没有答案