Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPressでデータベース接続の確立エラーを修正する方法

WordPressの’Error establishing a database connection’(データベース接続の確立エラー)通知は、ユーザーからサイトにアクセスできなくなる致命的なエラーです。WordPressがデータベースに接続できない場合に発生します。

この接続には複数の要因が影響する可能性があるため、初心者がこのエラーをトラブルシューティングするのは少し難しいかもしれない。

過去16年間WordPressでブログを運営してきましたが、「Error establishing a database connection」を含む様々なエラーや警告に遭遇してきました。私たちの経験と多くの試行錯誤を通じて、サイトを中断することなくこれらの問題をトラブルシューティングする方法を学びました。

この投稿では、WordPressサイトの「Error establishing a database connection(データベース接続の確立エラー)」を簡単に修正する方法を順を追って説明します。

Fix the Error Establishing a Database Connection in WordPress

WordPressのデータベース接続確立エラーの原因は?

データベースとは、データを簡単に保存、整理し、他のソフトウェアから取り出すためのソフトウェアである。

コンテンツ管理システムであるWordPressは、すべてのコンテンツやその他のサイトデータを保存するためにデータベースを使用します。そして、誰かがあなたのサイトにアクセスするたびにデータベースに接続します。

WordPressはデータベースに接続するために以下の情報が必要です:

  • データベース名
  • データベースのユーザー名とパスワード
  • データベースサーバー

この情報は、wp-config.phpと呼ばれるWordPressの設定ファイルに保存されます。

これらの情報に誤りがある場合、WordPressはデータベースサーバーへの接続に失敗し、「Error establishing a database connection(データベース接続の確立エラー)」というエラーが表示されます。

Database connection error in WordPress

WordPressで最もよく見られるエラーのひとつです。不正なログイン情報以外にも、データベースサーバーがダウンしていたり、データベースファイルが破損している場合にもこのエラーが表示されることがあります。

それでは、WordPressの「Error establishing database connection(データベース接続の確立エラー)」問題を解決する方法を、ステップ・バイ・ステップのトラブルシューティングとともに見ていきましょう。

1.WordPressデータベースのログイン情報を確認する

ログイン情報が正しくない ことが、データベース接続エラーの最も一般的な原因です。WordPressサイトを最近新しいホスティングサービスに移行した場合は、この問題が考えられます。

WordPressデータベースのログイン情報は、wp-config.phpファイルに保存されています。これはWordPressの設定ファイルで、データベース情報を含む重要な設定が含まれています。

wp-config.phpファイルを編集したことがない場合は、初心者向けのwp-config.phpファイルの編集方法をご覧ください。

wp-config.phpファイルで以下の行を探します:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** MySQL database username */
define( 'DB_USER', 'username_here' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

ここで、データベース名、ユーザー名、パスワード、データベースホストの情報が正しいことを確認しなければなりません。

この情報は、WordPressホスティングアカウントのダッシュボードから確認できます。このチュートリアルでは、Bluehost を使用しますが、他のホスティング パネルでも同様のプロセスになります。

ログイン中、左カラムの「ウェブサイト」タブをクリックし、「詳細設定」タブに切り替えます。次に、「データベース」セクションまでスクロールダウンし、その横にある「管理」ボタンをクリックします。

Click the Manage button next to the Database section

これにより、cPanelのMySQL Databasesページが新しいウィンドウで開きます。

ここで、’Current Database’ セクションにデータベース名とユーザー名があります。これらの情報をコピー&ペーストして、wp-configファイルに追加してください。

Find your database name and username in the Current Databases section

次に、「現在のユーザー」セクションまでスクロールダウンし、データベース名の横にある「パスワードの変更」リンクをクリックします。

新しい画面が表示され、データベースのパスワードを変更することができます。

Change your database password

データベースの詳細をすべて確認したら、必要に応じてwp-config.phpファイルで情報を変更できます。

その後、もう一度サイトにアクセスしてみて、データベース接続エラーがなくなっているかどうかを確認してください。

それでもエラーが表示される場合は、何か他の問題があることを意味します。

2.データベースホスティングサービス情報の確認

データベース名、ユーザー名、パスワードの情報が正確であることを確信している場合は、正しいデータベースホスティング情報を使用していることを確認してください。

ほとんどのWordPressホスティング会社は、データベースのホスティングサービスとしてlocalhostを使用しています。しかし、一部のマネージドWordPressホスティング会社は、データベースのホスティングサービスに区切りのサーバーを使用しています。その場合、データベースのホスティングサービスはlocalhostではありません。

つまり、WordPressホスティングサービス会社に連絡して、これらの詳細を確認する必要があります。

3.WordPressデータベースの修復

現在、wp-adminダッシュボードで「1つまたは複数のデータベーステーブルが使用できません」や「データベースの修復が必要な場合があります」など、別のエラーが表示されている可能性があります。その場合は、データベースを修復する必要があります。

これは、wp-config.phpファイルに以下の行を追加することで可能です。本当に〜してもよいですか?Happy blogging’の行の直前に追加してください:

define('WP_ALLOW_REPAIR', true);

設定が完了したら、このページhttp://www.yoursite.com/wp-admin/maint/repair.php。yoursite.comを自分のドメイン名に置き換えてください。

ここで、「データベースの修復」ボタンをクリックしてプロセスを開始する必要があります。

Repair WordPress database

注:データベース修復ページにアクセスするために、ユーザーはログイン中である必要はありません。データベースの修復と最適化が完了したら、wp-config.phpからこの行を削除してください。

しかし、サイトにコードを追加したくない場合は、ホスティングアカウントのcPanelを使用してデータベースを修復することもできます。

ホスティングサービスアカウントにアクセスし、左の列から「ウェブサイト」ページを開きます。次に、’Advanced’タブに切り替え、データベースセクションの’Manage’ボタンをクリックします。

Click the Manage button next to the Database section

新しいタブでcPanelが開きます。ここで、「データベースの修正」セクションまでスクロールダウンし、「データベースの修復」ドロップダウンメニューからデータベース名を選択します。

そうしたら、「データベースの修復」ボタンをクリックしてプロセスを開始する。

Click the Repair database button

ホスティングサービスパネルが自動的にデータベースを修復します。

プロセスが完了すると、成功のメッセージも表示されます。

Database repair success message

これでWordPressサイトにアクセスして、エラーが解決したかどうかを確認することができます。

4.データベースサーバーがダウンしていないか確認する

すべてが正しいように見えてもWordPressがデータベースに接続できない場合は、データベースサーバー(MySQLサーバー)がダウンしている可能性があります。

これは、サーバーのトラフィックが多いために起こる可能性があります。ホスティングサービスのサーバーが負荷に耐えられないのです(特に共有ホスティングの場合)。

このため、サイトが遅くなり、ユーザーによってはエラーが出力されることもあります。この場合、ホスティングサービスプロバイダーと電話またはライブチャットで、MySQLサーバーがレスポンシブかどうかを確認する必要があります。

さらに、同じサーバーで他のサイトを運営している場合は、それらのサイトをチェックして、SQLサーバーがダウンしていることを確認することができる。

同じホスティングアカウントに他のサイトがない場合は、ダッシュボードに移動し、[詳細設定]タブに切り替えるだけです。

その後、phpMyAdminセクションの横にある「管理」ボタンをクリックします。

Click the Manage button next to the PHPMyAdmin option

新しいウィンドウでphpMyAdminが開きますので、一番上の「データベース」設定をクリックしてください。

その後、データベースの名前をクリックして、その設定にアクセスしてください。それができたら、データベース・ユーザーに十分な権限があるかどうかをチェックしましょう。

Connect PHPMyAdmin with your database

そのためには、testconnection.phpというファイルを新規作成し、以下のコードを貼り付ける必要があります:

<?php
$link = mysqli_connect('localhost', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysqli_error());
}
echo 'Connected successfully';
mysqli_close($link);
?>

コードを貼り付けたら、ユーザー名とパスワードを自分のものに置き換えてください。このファイルをサイトにアップロードし、ウェブブラウザーからアクセスすることができます。

スクリプトが正常に接続された場合は、ユーザーに十分な権限があることを意味します。

次に、wp-configファイルに戻り、すべての詳細が正確で、タイプミスがないことを確認するためにスキャンする必要があります。

ユーザーにとって効果的だったその他のソリューション

上記のトラブルシューティングのヒントでサイト上のデータベース接続エラーを修正できない場合は、以下の追加手順をお試しください。

ユーザーからの報告によると、これらの手順でサイト上のデータベース接続エラーを解決したユーザーもいます。

1.WordPressサイトのURL更新

cPanelのphpMyAdminを使ってWordPressサイトのURLを更新してみてください。

ホスティングアカウントのダッシュボードからphpMyAdminにアクセスし、リストからWordPressデータベースを選択するだけです。

その後、上部のSQLメニューに切り替え、次のMySQLクエリーを入力する:

UPDATE wp_options SET option_value='YOUR_SITE_URL' WHERE option_name='siteurl'

このように見えるはずだ:

Change site URL

WordPressのテーブル接頭辞を変更している可能性があるので、自分のサイトURLをプロバイダーで指定し、wp_optionsを自分のテーブル名に変更することをお忘れなく。

2.Webサーバーの再起動

専用サーバー、ローカルサーバー、仮想専用サーバー(VPS)のユーザーは、サーバーの再起動を試すことができる。

これによりWebサーバーとデータベースサーバーが再起動され、エラーの原因となる一時的な不具合が修正される可能性があります。

3.助けを求める

他のすべてがうまくいかない場合は、ホスティングサービス会社に連絡する必要があるかもしれません。すべての優れたWordPressホスティングサービス会社は、トラブルシューティングを手伝い、正しい方向を示し、あるいは問題を解決してくれます。

WPBeginnerプロサービスのようなプラットフォームを使ってWordPress開発者を雇い、リーズナブルな料金でこの問題を解決することもできます。WPBeginner Pro Services には、WordPress の問題を解決するために信頼できる専門の開発者チームがあります。

WPBeginner Pro Services

サイトのメンテナンス、ハッキングされたサイトの修復、スピードの最適化、サイトの再構築、SEOの最適化などのサービスも利用できる。

この投稿がWordPressの「Error establishing a database connection」問題の解決に役立てば幸いです。WordPressの問題を自分で解決するためのヒントについては、WordPressトラブルシューティングガイド、またはWordPressでカスタムデータベースエラーページを追加する方法についてのチュートリアルもご覧ください。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

アバター

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

662件のコメント返信を残す

  1. Abul Fayes

    Either ‘127.0.0.1:8889’ or ‘localhost:8889’ works for me. Just using ‘localhost’ with no port specified does not work. I am using MAMP

  2. Joe

    The frontend of my site is connecting but the wp-admin section is showing the error establishing a database connection.

    What do I do?

  3. ALEX

    Thank you, it worked!!! :)

  4. Gill

    Thanks! Life saver. Completely borked my site changing passwords. Could have sworn I’d done everything right but managed to fix it in config.

  5. Praveen

    My problem was due to a google analytics plugin, the day i installed it, my site was down saying “Error database connection!” Even I was unable to login into my admin panel. So, I manually removed that plugin from cpanel, and everything worked.

    • Andreja

      Hi Praveen,

      thank you for your info. Can you please explain how to find particular plugin in cpanel to remove it? I received this error message right after I’ve installed “All in one SEO pack” plug-in in my Worpress site so I guess it could be the same problem as your problem was…?

      Thank you in advance!

  6. Matt

    I was on a Digital Ocean 512MB droplet and was getting this error every couple of weeks. Inspecting the logs showed that a process called update-apt-xapi was consuming all of my memory and causing the mysql service to crash resulting in the error. You can try setting up a swap file but, really, 512MB just isn’t enough memory to run a Wordpress install. Upgrade your droplet to 1GB and that should take care of the issue.

    • Joween Flores

      We have the same issue here friend. How’s your website going since? I was trying to cheap on server expenses now.

  7. Ob

    I just checked MySQL server with “service mysql status”. Apparently, MySQL server was not running.
    So, I started it with: “service mysql start”. And Voila! my website was up.

  8. Kishan SHarma

    What i found is it was faulty plugin which was causing trouble , try deactivate plugins and check if problem persist. changing localhost to 127.0.0.1 also solved some issues

  9. Jim Zimmer

    I did a search through your post and didn’t find anything about SELinux being the culprit, which ultimately was my problem. I have segregated my web server from my database and disabled SELinux on both VMs. I tried your testconnection.php, which was successful from within the /var/www/html directory before disabling SELinux, so I really have no idea if it is the database or the web server that has the issue. I will try and update this comment with SELinux settings that work when I have tested it.

  10. Andrea

    I have this problem right after having changed the password for my admin access. Can you super kindly provide a solution written in a language understandable for someone who has close to 0 programming or web-developer knowledge?? I have the error for both front-end and back-end. I have NO IDEA how to “check the wp-config.php” file (never heard of it until now). How do I proceed?

    Thank you so much,
    Best,
    Andrea

  11. Binyam

    What did work for me was this: In cPanel, go to Advanced Zone Editor select the domain copy the recorded IP and as wpbeginner suggested I replacing localhost with the IP and it works! Thanks!

  12. Avinash

    I was having the connection problem. The problem was my previously installed MySQL, was running. So I stopped it and then ran MySQL of Xampp. It worked. Hope it helps.

  13. Avinash

    My previously installed mySQL was running. I stopped it and then ran mySQL that came with Xampp. it worked. Hope it helps.

  14. Swati

    We had our wordpress installed on AWS EC2 and we got the “Error establishing database connection” for all our sites when the database was installed on the same server as the web server. When the database was moved to Amazon RDS for each of our sites, that error did not recur.

  15. Luis Daniel

    Hi!
    This helped me a lot with a WP installation going bad. Thanks!

  16. Scott

    Greetings.

    I have recently experienced the same issue when moving my multi-site from a subdirectory to root. Even after going through all the steps outlined in various tutorials, I encountered this dreaded message and nothing I did seemed to work.

    What did work for me was this: In cPanel, go to your softaculous script installer, select the edit icon for your WordPress installation, change the paths that point to your install.

    Once I did this and saved, then navigated to my site URL, it was back up and running smoothly.

    Just wanted to leave this here in case it helps someone else along the way.

  17. John Henry Gaspay

    Thanks man, it work on ngnix server due to error establishing.

  18. Sysy

    I have an issue with database connection. I wanted to create a new database for a new website #2 connected in multisite in OVH, and when wordpress asked me to enter login, password etc I entered those of website #1 as I had to do BUT without changing “wp_” for “wp_2″… And now both of these two sites have the message “Error establishing a database connection”. I deleted all FTP WP for website #2 and deconnected from multisite, but impossible to get back and to enter in website #1!! Do you know how to resolve this problem?

  19. Taurai

    I’m having an issue with my website, my WordPress database just seams to disappear. logged into MySQL and nothing exist there anymore. has anyone ever experienced this? anyone with a solution?

  20. Gail Gardner

    The cause of this issue when I had it was so many people running hacking programs against my login page that they were impacting the server. It happened every Friday evening through Sunday evening.

    We eliminated the issue by protecting that page with a pop-up so they couldn’t run their automated hacking programs against the login page.

  21. Rita

    Thank you for posting this–it saved a bit of a panic when the company’s WP blog disappeared behind this error. After verifying that the database was still there and undamaged, I called our host.

    Turns out they’ve been migrating customers’ web sites to new and improved servers, and they somehow lost the connection info. Hopefully it will be repaired today.

    But a very informative article, and a quick reminder (for me) of how to check in on mySQL to make sure everything is still good. Thanks!

  22. adams

    i cant create pages, new post, or edit my themes or even upload pictures i constantly get the following error…

    This page isn’t working.
    didn’t send any data.
    ERR_EMPTY_RESPONSE
    the website setup is new but am faced with this problem

  23. Wayne

    Thanks. Helped me debug a DB backend issue.

  24. jitesh

    How can i find my wordpress database username and password?

    By Mistake, i have deleted wp-config.php file and now i have uploaded new files.

    I am Using Godaddy’s windows server…

    I am getting below error:

    This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at . This could mean your host’s database server is down.

    Are you sure you have the correct username and password? Are you sure that you have typed the correct hostname? Are you sure that the database server is running? If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

    Please help me as I have wasted by complete week…

    Thank you..

    • WPBeginner Support

      Hey Jitesh,

      You can login to your hosting control panel and locate the MySQL database section. Most likely, you will be able to find the database name, username, and password information there. Alternately, you can contact support to help you locate that information.

      管理者

  25. Bob

    Thanks so much, all, for maintaining such a great website! You guys continue to bail me out with problems, issues & fixes for those of us who just enjoy writing & posting and not dealing with all of the WordPress programming stuff. Great work!
    Cheers!!!!

  26. Joette

    Thanks for all the great articles. I am having such a problem tho just getting WP installed. I’ve followed your instructions regarding doing it with MAMP and keep getting the “can’t connect to localhost:8888” msg. After much searching I found a terminal code to test apache. It returned with httpd not running, trying to start. I did it again and it didn’t return anything so perhaps worked.

    I tried connecting to local host again and this time I got Error connecting to database. At least this seems like progress! I tried some of your suggestions above and this time, it seemed to be trying to connect for quite a while, but finally gave me the Error connecting to database again.

    I have yet to get the happy WP page. Does anyone at all have any ideas as to what is going on? I have spent hours searching, contacting, trying this and that and I don’t know what else to do at this point. I am an absolute WP beginner.

    Thanks to anyone/everyone in advance.

    • Ashley Knox

      Hey! Were you able to figure it out? I’ve tried all of their solutions and I’m still stomped.

      • Joette

        Hi Ashley, No, unfortunately nothing is working for me either! I’ve yet to find someone who knows the answer & have been asking many places. For me, I think I’m going to use different software and leave WP for another time. Too strange, too much hassle.

        • Kalico

          This isn’t a WordPress problem, it’s a MAMP problem. If you have to run this on a local server, try a different XAMP package. Better yet, get a shared hosting account and set it up there. Local XAMP can be frustrating.

  27. J M Landers

    I missed that when you add the repair line to your WP config file you have to add it right at the end of the declarations before the first “if” statement when I first read it. Took me a while to realize what I was doing wrong. Still didn’t fix my problem but at least I was able to strike one possible issue off my list.

  28. Muhammad Qamar40391

    Thank you for a great helpful post.
    Solved by resetting DB password but this process repeated several times. issue solved but page speed is too much slow now.

  29. John Malto

    Also had the same problem and tried everything. TestConnection was failing. What I just had to do was manually edit the user password through MySQL Cpanel and it suddenly worked!

  30. Leslie limardo

    I am so confused. First time on wordpress. No tech experience whatsoever. I didn’t receive any error. message. My website is up. The problem I had is when I set the page to update some updates would take effect and others didn’t. I called Wordpress and they told me I didn’t set up the database correctly. Is this the same issue as this article or something totally different? Thanks in advance.

  31. Fran

    Hi, i had this problem when I formatted my laptop and reinstalled XAMPP.

    Problem was, I forgot to create a new Mysql user with the same data (host, name and password) from my BD user stored on wp-config.php, just like we do when we configure one new WP site for the first time. That solved it :)

    So, maybe the problem is not that the user has not enough permissions… perhaps the problem is, user simply doesn´t exist yn mysql.user table! (as I said, it can be possible after formatting your computer).

  32. Ahmed

    thank you for the great help, i got mine up by replacing localhost with 127.0.0.1

  33. Kate

    I just had the same problem, which I managed to solve by simply changing the DB password and correcting that in the config.php file.

    I have no idea why the password suddenly became an issue, though.

  34. Sheriph

    Changing the localhost in my wp-config.php to the ip on my host account in godaddy cpanel did the magic for me. Even godaddy support were talking rubbish. Imagine telling to upgrade with about $200, that my hosting plan is low on resources. I almost believed until I found this article. Thanks a lot.

    • Steve

      I still have the problem. GoDaddy tried but unable to help. They have a service that, for $80.00, will have a WordPress expert investigate. However, there are no guarantees she / he can fix the problem but you still have to pay the $80.00.

  35. Destiny Alabi

    This review was very helpful,

    I had a similar issue with installation on windows server, I kept getting database error, and what I did was to replace localhost which was internal server to IP Address and Port which was external server and it worked perfectly.

  36. Sam

    Mine just happened like 20 minutes ago, I am hosting at Ipage and WHAT A SCARE!!! It happened all over sudden and I could not access both the admin site and the website itself with my laptop but I could access the site with my phone.
    Then before I could complete reading this guide the site got back by itself lol. I want to know if there is a way to avoid this from happening in future.

    • Robin Robin

      The same happened with my site. Very strange!

  37. Aaditya Koesis Sharma

    Nice article. I want to know about the AMP errors and how to fix them ?

    • Bongani Ngcobo

      This was helpful, Thank you very much. I always rely on WP Beginner when struggling.

  38. sreekan th reddy

    my website is showing database connection error .

    can some one help me to solve the problem

    my website is created in amazonweb service

    for every 24 hours it showing database connection error
    the php-myadmin ,wp-content every thing is fine
    can plz some one help to solve this issue

  39. Martin L.

    I have no WordPress account, but have been having this happen to me a lot recently on several sites. How can I fix this? (Note: I don’t own these other sites and I don’t think I can access their databases directly)

  40. imparthi

    Thanks much for the article. I ran into the same issue.
    1. Wp-Config file was correct
    2. phpMyadmin connection was success
    3. testconnection.php approach too was success
    4. I tried to update the site URL I couldn’t get it as naming conventions of the table names of the WP changed

    THIS IS WHAT HELPED ME FINALLY.
    I selected wp_Options” table in the phpMyAdmin window to browse the content, there was an informative Error message that, the table has to be repaired. (wp-config auto-repair didn’t work out)

    I was able to repair using the options available in phpMyAdmin and got my site back. :) Thanks all.

  41. jhaejhae jhaens

    hi there.. can i please seek help.. i am working now on transferring my live WordPress site to local using XAMPP.. my database is doing good but i cant connect it during the WordPress installation. please help.. thanks in advance!

  42. Tanya

    Hi there,

    Thank you for this article. My website was hacked recently and after I got no support from the hosting provider, I was told I was going to need to reinstall Wordpress and upload the backup. I didn’t use a backup plugins (I am all the way in South Africa) as it is to expensive for the paid plugins. So I did a cpanel backup through Softaculous and downloaded the Zip of 1.03Gig. Two weeks later my site was hacked (Twice in one week). With the second hack my wordpress installation was comprimised – and backup deleted from server. So I had to delete the original installation and reinstall. Now I followed all the steps to upload the zip to file manager and now I am stuck with this: Error Establishing a Database Connection. I have tried all the suggested solutions from this post, but still no progress. Please help me! I am quite new to wordpress and this is my biggest client’s website.
    Kind regards,
    Tanya

    • WPBeginner Support

      Hi Tanya,

      The most common reason for this error is incorrect Database information in your wp-config.php file. Confirm that you have restored your WordPress database correctly, then enter the mysql host, database name, database username and password carefully. If you are unsure, ask your hosting provider and they will let you know your mysql host and other information.

      Hope this helps

      管理者

  43. Mannu

    Some folks suggested that they fixed their problem by replacing localhost with the IP.

    It worked for me….
    Any logical explanation for this…?

    • Nick

      Think about it. ‘Localhost’ is the name of a location. If changing that to the IP works, then ‘localhost’ was not pointing where you need it to be.

  44. Andrew

    Thank you for your article, it was very informative and helpful in getting my issue resolved.

  45. Ravi

    I have MAMP installation on my Macbook. i.e I am running MySQL also on my local machine. My problem was that in wp-config.php, the database server ‘localhost’ is not working. Once I changed it to 127.0.0.1, it started working.

  46. Amanda

    What does it mean if testconnection.php is just a blank white page?

  47. Mike Crisp

    Repair database command worked for me.
    Front end or site was fine but couldn’t access admin panel – Repair found a damaged database file (wp-options) – repair worked

  48. JP Hoey

    What i did was, in the cPalen i went into MySQL databases and scrolled down to current user and changed the password. I used the very same password that was in my wp-config.php file but for some reason the password was corrupt. Everything works fine now.

    • Chuck Moran

      I got this error on a client’s site. After a bum steer chatting with a Bluehost tech, I called back and the phone tech support person I got did this same @JP Hoey trick (changing the DB pass and updating it in wp-config.php). Took 5 minutes and worked like a charm.

  49. Adam Coalbow

    An obscure one for me…

    Don’t use #’s in your password.

    I had two hash tags in my password that was throwing something off in the PHP–since hash tags create comments I guess. I removed the hash tags and BOOM, I’m in.

  50. Ted Richards

    First thank you for a well-documented article on “We were able to connect to the database server (which means your username and password is okay) but not able to select the XXXXXX database.”

    I tried almost everything outlined in the article but can’t fix my problem. Here is an outline and history.

    Local machine installation:
    I have installed MySQL 5.7.17 and MySQL WorkBench 6.3.8. And WordPress 4.7.2. The MySQL was installed after removing both an earlier version of MySQL and WorkBench. The previous version was displaying the same database error. The previous WordPress/MySQL worked about 2 years ago, but recently I contracted a project to develop a WordPress Web site, and I encountered this problem when I began setting up the new WordPress framework for this new site. The old WordPress site was deleted so I couldn’t test if that worked.

    So, I reasoned, why not try a fresh start and also upgrade to the latest versions, etc.

    But, this new version also had the same problem with not being able to connect to the database. I have narrowed down the problem to “permissions” and I haven’t been able to crack the code.

    The MySQL Server logs verify this is this case:
    Timestamp, Thread, Type, Details
    2017-01-28T02:46:24, 134, Note, Access denied for user ‘root’@’localhost’ (using password: YES)

    I have created a new WP directory and installed a fresh WP version etc.
    I deleted and created new databases in WorkBench and properly assigned them users and passwords.

    I have checked the Users and Privileges, Client Connections and can find nothing that would block access to the database.

    I have checked my Windows 7 permissions for the MySQL Directory and the sub directories. I have unchecked the “Read Only” to the master MySQL Directory and all directories and files are read/write.

    I have progressed through each attempt to connect to the database each time I change something.

    I am exhausted and very disappointed there isn’t a good response by the WP Support Team to this issue of “not able to select the database.” It is a “popular” issue that many developers are experiencing with no resolution–many more experienced than me, are having.

    You are my last hope!

    Thank you!

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。