嗨,在我的codeigniter应用程序中,当我尝试连接mysql数据库时,发生了以下错误。
消息:mysqli::real\u connect():(hy000/2002):连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机没有响应。
我使用的是windows10系统
xampp 3.2.2版
php版本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
暂无答案!
目前还没有任何答案,快来回答吧!