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屋!