我整个下午都有问题而且我很坚持,所以,让我们解释一下。
我正在运行MariaDB,它是Fedora Linux Distibution的mysql的一种风格。 我试图在我的本地机器上安装需要数据库后端的php cms,所以我创建了数据库(这不是第一次,所以我应该知道我和我#39; m),让我们说它被称为myDb好吗?然后我创建了用户,让我们说myDbUser @ localhost好吗?然后,将db的权限授予用户(GRANT ALL是特定的)。然后我从数据库的命令行测试了用户和授予的权限,一切正常,我可以登录,我可以看到数据库。
然后我运行cms的安装脚本好吗?
Database type: MySQL (or compatible)
Database host: localhost
Database name: myDb
Database username: myDbUser
Database password: passowrd
从命令行运行的相同数据。但结果是:
DB connection error: Permission denied (localhost).
Check the host, username and password and try again.
鉴于用户名和密码在命令行中工作正常,我认为这是"主机" ..
的问题所以我花了整整一个晚上试图了解它的错误,我唯一能说出来的东西(我知道它并不多)是这个命令的输出:
netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2393 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 :::80 :::* LISTEN
我尝试了所有这些知识产权的人都没有成功。我总是得到同样的错误,所以任何想法,提示,线索,甚至是片段虽然?感谢。
编辑:所以进一步的研究表明问题不是数据库问题,而是CMS问题。这是因为我可以使用给定的用户和密码从命令行连接到db。
EDIT2:其他研究表明问题可能是permission problem.我从我的机器的root用户登录到db,但是webserver正在从其他用户访问它。我仍然不知道如何解决这个问题。
EDIT3:这是apache服务器的日志文件:
/var/www/html/Wiki/includes/limit.sh: line 61: ulimit: cpu time: cannot modify limit: Permission denied
/var/www/html/Wiki/includes/limit.sh: line 90: ulimit: file size: cannot modify limit: Permission denied
之前有人遇到过类似的问题,可以提供帮助吗?我有这两个链接: 1 2但他们似乎没有帮助我,因为我不明白为什么这个脚本无法运行这些命令。
答案 0 :(得分:0)
如果您不熟悉MySQL权限的工作方式,只需向MediaWiki安装程序提供root密码,它就会为自己创建具有正确权限的用户。
答案 1 :(得分:0)
您可以尝试使用'%'代替localhost来提供'youUser'@'%'等权限。 这应该有用。
答案 2 :(得分:0)
嗯,它出来了根本不是MySql或PHP的问题。相反,这是一个安全问题,服务器没有访问mysql通道的权限。我不得不使用这些命令修复它:
# grep httpd /var/log/audit/audit.log | audit2allow
# semodule -i mypol.pp
我真的很难找到这个解决方案,我不得不去寻找带有journalctl的系统消息(以前我不知道的命令)。所以这是一个很大的皮塔饼*但我终于找到了它。
所以,如果有人会遇到类似的问题,至少答案就在那里。
答案 3 :(得分:0)
实际上,你需要的是
setsebool -P httpd_can_network_connect_db 1
我总是,每一个!单!时间!,当我设置一个新的主机时碰到一个或多个selinux问题。每次我最终都会搜索问题,通常是几个小时,然后我才开始运行sealert -a并自己处理它。
所以,你必须先了解一下如何阅读
sealert -a /var/log/audit/audit.log
向您展示了应用的grep解决方案。你需要进一步阅读。你的输出看起来如下(注意问题,第一次粘贴的线,以及建议的解决方案,他们有信心,你被选为一个相当短暂):
SELinux is preventing /usr/sbin/httpd from name_connect access on the tcp_socket .
***** Plugin catchall_boolean (47.5 confidence) suggests *******************
If you want to allow HTTPD scripts and modules to connect to the network using TCP.
Then you must tell SELinux about this by enabling the 'httpd_can_network_connect'boolean.
Do
setsebool -P httpd_can_network_connect 1
***** Plugin catchall_boolean (47.5 confidence) suggests *******************
If you want to allow HTTPD scripts and modules to connect to databases over the network.
Then you must tell SELinux about this by enabling the 'httpd_can_network_connect_db'boolean.
Do
setsebool -P httpd_can_network_connect_db 1
***** Plugin catchall (6.38 confidence) suggests ***************************
If you believe that httpd should be allowed name_connect access on the tcp_socket by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep httpd /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp
Additional Information:
Source Context unconfined_u:system_r:httpd_t:s0
Target Context system_u:object_r:mysqld_port_t:s0
Target Objects [ tcp_socket ]
Source httpd
Source Path /usr/sbin/httpd
Port 3306
Host <Unknown>
Source RPM Packages httpd-2.2.15-54.el6.centos.x86_64
Target RPM Packages
Policy RPM selinux-policy-3.7.19-292.el6.noarch
Selinux Enabled True
Policy Type targeted
Enforcing Mode Enforcing
Host Name publicsrv
Platform Linux publicsrv 2.6.32-642.el6.x86_64 #1 SMP Tue
May 10 17:27:01 UTC 2016 x86_64 x86_64
Alert Count 26
First Seen Sat 01 Oct 2016 09:14:01 PM EEST
Last Seen Sat 01 Oct 2016 11:23:12 PM EEST
Local ID 064b82b4-2e50-42ea-9a07-11468d0a62a6
Raw Audit Messages
type=AVC msg=audit(1475353392.72:578): avc: denied { name_connect } for pid=5858 comm="httpd" dest=3306 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:mysqld_port_t:s0 tclass=tcp_socket
type=SYSCALL msg=audit(1475353392.72:578): arch=x86_64 syscall=connect success=no exit=EACCES a0=e a1=7f0cd22a6008 a2=10 a3=40 items=0 ppid=5852 pid=5858 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1 comm=httpd exe=/usr/sbin/httpd subj=unconfined_u:system_r:httpd_t:s0 key=(null)
Hash: httpd,httpd_t,mysqld_port_t,tcp_socket,name_connect
audit2allow
#============= httpd_t ==============
#!!!! This avc can be allowed using one of the these booleans:
# httpd_can_network_connect, httpd_can_network_connect_db
allow httpd_t mysqld_port_t:tcp_socket name_connect;
audit2allow -R
#============= httpd_t ==============
#!!!! This avc can be allowed using one of the these booleans:
# httpd_can_network_connect, httpd_can_network_connect_db
allow httpd_t mysqld_port_t:tcp_socket name_connect;