Codeigniter使用centOS和mariadb作为数据库管理连接到SSH服务器的可能设置是什么? [英] What is the possible setting for Codeigniter connecting to a SSH server with centOS and mariadb as database management?
问题描述
我正在使用的服务器是ssh连接,由centOS运行,它使用LAMP作为平台.
The server I'm using is an ssh connection, which is ran by centOS, it uses LAMP as platform.
因为它是centOS,所以mariadb是它唯一可用的数据库管理.我无法通过sudo yum install mysql-server
命令安装mysql.
Because it is centOS, mariadb is the only available database management for it. I cannot install mysql via sudo yum install mysql-server
command.
我已经在本地使用codeigniter创建了一个项目.
I've created a project using codeigniter in my local.
我无法连接到数据库.该错误显示为:
I'm having trouble connecting to the database. The error gives like:
A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Filename: mysqli/mysqli_driver.php
我的codeigniter中的db设置是:
The db setting in my codeigniter is:
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => '*server-ip-address*',
'port' => '*server-port-number*',
'username' => 'root',
'password' => 'root@999',
'database' => 'listingapp_db',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
我只是以为我的数据库设置可能是错误的.
I just thought that maybe my database setting is wrong.
与dbdriver
设置有关吗?
我尝试将mysqli
更改为mariadb
,仍然没有任何进展.
Has it something to matter with the dbdriver
setting?
I tried changing mysqli
to mariadb
, still no progress.
可以与服务器的centOS mariadb一起使用的有效设置是什么?
What could possibly be the valid setting that could co-inside with the server's centOS, mariadb?
我尝试了sudo iptables -vnL检查防火墙,这是结果:
I tried sudo iptables -vnL to check firewall and this is the result:
Chain INPUT (policy DROP 10924 packets, 630K bytes)
pkts bytes target prot opt in out source destination
40905 5353K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
1860K 2702M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x3F/0x00
4 172 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:!0x17/0x02 state NEW
0 0 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x3F/0x3F
158 9480 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
445 28059 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
57 2800 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:2202
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 1133K packets, 103M bytes)
pkts bytes target prot opt in out source destination
推荐答案
我现在已经解决了我的问题.只需打开我使用的端口,然后向mysql中的root用户授予特权即可.
I have now fixed my issue. It's a matter of opening the port I used then granting privilege to the root user in mysql.
这篇关于Codeigniter使用centOS和mariadb作为数据库管理连接到SSH服务器的可能设置是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!