[英]WordPress login screen database issue
My WordPress login page at mysite.com/wp-login.php is giving me a cannot connect to 127.0.0.1
error. 我在mysite.com/wp-login.php上的WordPress登录页面给我一个
cannot connect to 127.0.0.1
错误。
The site works, and other WordPress admin pages are available, like upgrade.php
. 该站点可以正常运行,并且可以使用其他WordPress管理页面,例如
upgrade.php
。 I've done some googling, tried some of the suggestions here: http://wordpress.org/support/topic/error-establishing-a-database-connection-112 我已经进行了一些谷歌搜索,在这里尝试了一些建议: http ://wordpress.org/support/topic/error- Establishment-a-database-connection-112
But to no avail. 但无济于事。 Admin has been working for weeks and nothing has been changed.
管理员已经工作了数周,没有任何更改。 Everything also looks correct in config.php.
config.php中的一切看起来也正确。 The site is on AN Hosting, and I logged into the phpMyAdmin on the cPanel and everything seems to be in order with the database
该站点位于AN Hosting上,我登录了cPanel上的phpMyAdmin,数据库似乎一切正常
I have very little experience with database issues and MySQL, so I am a little flummoxed. 我对数据库问题和MySQL的经验很少,所以有点困惑。
Same problem. 同样的问题。 AN Hosting is blocking you.
托管服务正在阻止您。 They are blocking any attempt to login on some of their shared servers.
他们阻止任何尝试登录某些共享服务器的尝试。 I changed wp-login.php page to a new address, and corrected all references in the WordPress folder.
我将wp-login.php页面更改为新地址,并更正了WordPress文件夹中的所有引用。
Now everything works fine. 现在一切正常。 However, it will only work until the next update.
但是,它仅在下一次更新之前有效。
AN Hosting says they are doing this only temporarily because they've been facing some type of attack on WordPress logons. AN Hosting表示,他们之所以只是暂时这样做,是因为他们在WordPress登录时遭受了某种形式的攻击。 If you ask me this is very lame.
如果你问我,这很la脚。 They need to resolve this issue.
他们需要解决此问题。
Call them! 给他们打电话! I will also call them again and complain.
我也会再次打电话给他们并抱怨。
Thats strange if it was working before, and not now. 如果它在以前而不是现在可以正常工作,那就太奇怪了。
I'm used to get trouble connecting to my database with WordPress (since I'm installing WordPress websites many oftern) , but when ever it failed for me the problem were in the hostname
我习惯于使用WordPress连接到我的数据库时遇到麻烦(因为我要安装很多网站来安装WordPress网站) ,但是一旦它对我失败了,问题就出在主机名上
I would suggest you to check your database hostname, if you can log in to cPanel you can find out form the data base interface 我建议您检查数据库主机名,如果可以登录到cPanel,则可以从数据库界面中查找
Look here: 看这里:
Then check this section for the hostname: 然后检查此部分的主机名:
If you specified correctly there should be no problem 如果指定正确,应该没有问题
After seen the comment you left after your question, this came to my mind 在看到您提出问题后留下的评论后,我想到了这一点
Go into 进入
PhpMyAdmin -> Your WP Database -> Options Table and check the site url value, it might be still pointing to your old dev url
PhpMyAdmin- > 您的WP数据库 -> 选项表,并检查站点url值,它可能仍指向您的旧dev url
So based on the answer given by @user3035755 , I can give you the following work-around: 因此,根据@ user3035755给出的答案,我可以为您提供以下解决方法:
In your root directory, create a file called(for instance - you can change that if you want to) login.php
(not sure if the word "login" would be accepted - you might have to play around with it a bit, until something works). 在您的根目录中,创建一个名为(例如,您可以更改)
login.php
(不确定是否可以接受“ login”一词-您可能需要多花点功夫,直到的东西)。 In this file add the following code: 在此文件中添加以下代码:
<?php
include_once( dirname( __FILE__ ) . '/wp-login.php' );
This code will include the original wp-login.php file. 此代码将包含原始的wp-login.php文件。 I'm not sure how their restriction works - if it's based on where the call to the database is being made(as in from which exact file), then it might fail due to the fact that the connection would still be made from
wp-login.php
(although I assume that's not how they did it). 我不确定它们的限制是如何工作的-如果它是基于对数据库的调用位置(例如从哪个确切文件中),则由于连接仍将由
wp-login.php
建立,因此它可能会失败- wp-login.php
(尽管我认为那不是他们的方式)。 If they instead check the file that is being executed, then you should be fine(since in that case it would be login.php
- again, you might have to change that). 如果他们改为检查正在执行的文件,则应该没问题(因为在这种情况下,它将是
login.php
再次,您可能必须更改它)。
Now, that's just the first step - you can either manually go to login.php every time you want to log-in, but it'd be better if the login URL is automatically adjusted. 现在,这只是第一步-您可以在每次想要登录时手动进入login.php,但是最好是自动调整登录URL。 To do that, go to the
/wp-content/
directory and create(if it doesn't already exists) a mu-plugins
1 directory. 为此,请转到
/wp-content/
目录并创建(如果尚不存在) mu-plugins
1目录。 In there create a new file, called new-login.php and in that file put the following code: 在其中创建一个名为new-login.php的新文件,并在该文件中添加以下代码:
<?php
/*
Plugin Name: New Login URL
Plugin Description: Makes the login URL /login.php instead of /wp-login.php
*/
function nl_login_url_filter( $login_url ) {
return str_ireplace( home_url( '/wp-login.php' ), home_url( '/login.php' ), $login_url );
}
add_filter( 'login_url', 'nl_login_url_filter', 10 );
function nl_logout_url( $logout_url ) {
return str_ireplace( home_url( '/wp-login.php' ), home_url( '/login.php' ), $logout_url );
}
add_filter( 'logout_url', 'nl_logout_url', 10 );
So what happens in this plugin, is that it simply hooks to the login_url
and logout_url
filters and changes http://mydomain.com/wp-login.php?test1=23&test4=56
to http://mydomain.com/login.php?test1=23&test4=56
. 因此,此插件中发生的事情是,它仅挂接到
login_url
和logout_url
过滤器,并将http://mydomain.com/wp-login.php?test1=23&test4=56
更改为http://mydomain.com/login.php?test1=23&test4=56
。
This way you don't have to take care of always entering login.php instead of wp-login.php. 这样,您不必总是输入login.php而不是wp-login.php。
Again - if that doesn't work, try using a different name for the file, like enter.php
(for instance), just remember to change the file name in the new-login.php
file as well. 再次-如果不起作用,请尝试为文件使用其他名称,例如
enter.php
(例如),只需记住还要在new-login.php
文件中更改文件名。
Footnotes: 脚注:
Been there done that, but that does not mean my guide-lines have the same positive result 到那里去做那件事,但这并不意味着我的指导方针具有相同的积极结果
for you but maybe it helps a little. 为您服务,但也许会有所帮助。 Below a small roadmap with steps you could take:
在一个小的路线图下,您可以采取以下步骤:
define('WP_HOME','http://yoursite.com');// blog url define('WP_SITEURL','http://yoursite.com'); // site url
Did it make any change for login? 它对登录有任何更改吗? maybe you check the phpMyAdmin ( through cPanel ).
也许您检查phpMyAdmin( 通过cPanel )。
wp_options
( the $table_prefix = '???_'
??? is what you have put there, wp_options
( $table_prefix = '???_'
???是您输入的内容, Now look at line 1 option_id
1 / option_name
siteurl / option_value
here must be your domain url. 现在看第1行
option_id
1 / option_name
siteurl / option_value
这里必须是您的域URL。
Now find around line 36 option_id
36 / option_name
home / option_value
here should be your domain url. 现在在第36行找到
option_id
36 / option_name
home / option_value
此处应为您的域网址。
IF they where not correct I assume you made corrections, saved them into the db and check if you are able to login now. 如果它们不正确,我假设您已进行了更正,将它们保存到数据库中并检查您是否能够立即登录。
define( 'WP_DEBUG', true ); // Or false to disable if ( WP_DEBUG ) { define( 'WP_DEBUG_LOG', true ); // writes errors down in wp-content/debug.log define( 'WP_DEBUG_DISPLAY', true ); // shows errors on screen output, set to false so only write into logfile define('SAVEQUERIES', true); // will have a performance impact so disable if not needed define('SCRIPT_DEBUG', true); // Use dev versions of core JS and CSS files (only needed if you are modifying these core files) }
If no debug.log is shown in wp-content you create the file by hand. 如果wp-content中未显示debug.log,则手动创建文件。
I hope that one of these will help you to find the solution. 我希望其中之一可以帮助您找到解决方案。
Ask your hosting provider what your database host should be and update the DB_HOST
line in wp-config.php
accordingly. 询问您的主机提供商,您的数据库主机应该是什么,并相应地更新
wp-config.php
的DB_HOST
行。
This is usually localhost
or 127.0.0.1
but on some hosts it may be something completely different that you would not be able to guess without asking - for example I've had long weird hostnames supplied by GoDaddy for this before (years ago when I still used GD for anything). 这通常是
localhost
或127.0.0.1
但在某些主机上可能完全不同,您必须先询问就无法猜测-例如,我以前有GoDaddy为此提供的长期古怪的主机名(几年前,当我仍然用GD做任何事情)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.