Local Worpdress website can not connect to its database











up vote
0
down vote

favorite












I am trying to install a Wordpress site on a local server (Ubuntu 16.04 in a docker container).



Xampp is installed and running, and I have created a database and a username with proper rights:



mysql -uroot -e "CREATE USER 'localuser'@'localhost' IDENTIFIED BY 'localpassword';";
mysql -uroot -e 'CREATE DATABASE 'localdatabase';';
mysql -uroot -e "GRANT ALL ON localdatabase.* TO 'localuser'@'localhost';";


I've also updated my wp-config.php file with the credentials above.



Still, when I try to install wordpress from there (I use wp-cli), I get the message "Error: Error establishing a database connection. 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 localhost. This could mean your host’s database server is down."



I've double checked the credentials, and xampp is indeed running, so what should I check next? Could this come from a config file that is missing something?










share|improve this question


























    up vote
    0
    down vote

    favorite












    I am trying to install a Wordpress site on a local server (Ubuntu 16.04 in a docker container).



    Xampp is installed and running, and I have created a database and a username with proper rights:



    mysql -uroot -e "CREATE USER 'localuser'@'localhost' IDENTIFIED BY 'localpassword';";
    mysql -uroot -e 'CREATE DATABASE 'localdatabase';';
    mysql -uroot -e "GRANT ALL ON localdatabase.* TO 'localuser'@'localhost';";


    I've also updated my wp-config.php file with the credentials above.



    Still, when I try to install wordpress from there (I use wp-cli), I get the message "Error: Error establishing a database connection. 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 localhost. This could mean your host’s database server is down."



    I've double checked the credentials, and xampp is indeed running, so what should I check next? Could this come from a config file that is missing something?










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am trying to install a Wordpress site on a local server (Ubuntu 16.04 in a docker container).



      Xampp is installed and running, and I have created a database and a username with proper rights:



      mysql -uroot -e "CREATE USER 'localuser'@'localhost' IDENTIFIED BY 'localpassword';";
      mysql -uroot -e 'CREATE DATABASE 'localdatabase';';
      mysql -uroot -e "GRANT ALL ON localdatabase.* TO 'localuser'@'localhost';";


      I've also updated my wp-config.php file with the credentials above.



      Still, when I try to install wordpress from there (I use wp-cli), I get the message "Error: Error establishing a database connection. 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 localhost. This could mean your host’s database server is down."



      I've double checked the credentials, and xampp is indeed running, so what should I check next? Could this come from a config file that is missing something?










      share|improve this question













      I am trying to install a Wordpress site on a local server (Ubuntu 16.04 in a docker container).



      Xampp is installed and running, and I have created a database and a username with proper rights:



      mysql -uroot -e "CREATE USER 'localuser'@'localhost' IDENTIFIED BY 'localpassword';";
      mysql -uroot -e 'CREATE DATABASE 'localdatabase';';
      mysql -uroot -e "GRANT ALL ON localdatabase.* TO 'localuser'@'localhost';";


      I've also updated my wp-config.php file with the credentials above.



      Still, when I try to install wordpress from there (I use wp-cli), I get the message "Error: Error establishing a database connection. 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 localhost. This could mean your host’s database server is down."



      I've double checked the credentials, and xampp is indeed running, so what should I check next? Could this come from a config file that is missing something?







      wordpress xampp wp-cli






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 16:02









      Sulli

      170218




      170218
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          What hostname are you using in the wp-config? Also did the commands finish succesfully? For creating the db you used apostrophes instead of quotes. You can try the mysql client directly with mysql -u -p -h .






          share|improve this answer








          New contributor




          Andrei Dumitrescu-Tudor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.


















          • I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
            – Sulli
            Nov 10 at 20:23










          • Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
            – Andrei Dumitrescu-Tudor
            Nov 10 at 20:25










          • yes they are in the same container. You're saying I can not use localhost in this case?
            – Sulli
            Nov 10 at 20:42










          • If they are in the same container you can use localhost. I mistyped before.
            – Andrei Dumitrescu-Tudor
            Nov 10 at 20:46










          • ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
            – Sulli
            Nov 10 at 21:04


















          up vote
          0
          down vote













          In wp-config.php, use 127.0.0.1 instead of localhost for the database hostname.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240752%2flocal-worpdress-website-can-not-connect-to-its-database%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            What hostname are you using in the wp-config? Also did the commands finish succesfully? For creating the db you used apostrophes instead of quotes. You can try the mysql client directly with mysql -u -p -h .






            share|improve this answer








            New contributor




            Andrei Dumitrescu-Tudor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.


















            • I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
              – Sulli
              Nov 10 at 20:23










            • Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
              – Andrei Dumitrescu-Tudor
              Nov 10 at 20:25










            • yes they are in the same container. You're saying I can not use localhost in this case?
              – Sulli
              Nov 10 at 20:42










            • If they are in the same container you can use localhost. I mistyped before.
              – Andrei Dumitrescu-Tudor
              Nov 10 at 20:46










            • ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
              – Sulli
              Nov 10 at 21:04















            up vote
            0
            down vote













            What hostname are you using in the wp-config? Also did the commands finish succesfully? For creating the db you used apostrophes instead of quotes. You can try the mysql client directly with mysql -u -p -h .






            share|improve this answer








            New contributor




            Andrei Dumitrescu-Tudor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.


















            • I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
              – Sulli
              Nov 10 at 20:23










            • Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
              – Andrei Dumitrescu-Tudor
              Nov 10 at 20:25










            • yes they are in the same container. You're saying I can not use localhost in this case?
              – Sulli
              Nov 10 at 20:42










            • If they are in the same container you can use localhost. I mistyped before.
              – Andrei Dumitrescu-Tudor
              Nov 10 at 20:46










            • ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
              – Sulli
              Nov 10 at 21:04













            up vote
            0
            down vote










            up vote
            0
            down vote









            What hostname are you using in the wp-config? Also did the commands finish succesfully? For creating the db you used apostrophes instead of quotes. You can try the mysql client directly with mysql -u -p -h .






            share|improve this answer








            New contributor




            Andrei Dumitrescu-Tudor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            What hostname are you using in the wp-config? Also did the commands finish succesfully? For creating the db you used apostrophes instead of quotes. You can try the mysql client directly with mysql -u -p -h .







            share|improve this answer








            New contributor




            Andrei Dumitrescu-Tudor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            share|improve this answer



            share|improve this answer






            New contributor




            Andrei Dumitrescu-Tudor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            answered Nov 10 at 16:13









            Andrei Dumitrescu-Tudor

            874




            874




            New contributor




            Andrei Dumitrescu-Tudor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





            New contributor





            Andrei Dumitrescu-Tudor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.






            Andrei Dumitrescu-Tudor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.












            • I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
              – Sulli
              Nov 10 at 20:23










            • Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
              – Andrei Dumitrescu-Tudor
              Nov 10 at 20:25










            • yes they are in the same container. You're saying I can not use localhost in this case?
              – Sulli
              Nov 10 at 20:42










            • If they are in the same container you can use localhost. I mistyped before.
              – Andrei Dumitrescu-Tudor
              Nov 10 at 20:46










            • ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
              – Sulli
              Nov 10 at 21:04


















            • I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
              – Sulli
              Nov 10 at 20:23










            • Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
              – Andrei Dumitrescu-Tudor
              Nov 10 at 20:25










            • yes they are in the same container. You're saying I can not use localhost in this case?
              – Sulli
              Nov 10 at 20:42










            • If they are in the same container you can use localhost. I mistyped before.
              – Andrei Dumitrescu-Tudor
              Nov 10 at 20:46










            • ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
              – Sulli
              Nov 10 at 21:04
















            I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
            – Sulli
            Nov 10 at 20:23




            I'm using 'localhost' in wp-config.php. Yes the commands finish successfully. I checked with SHOW DATABASES; and SHOW GRANTS; , my database has been created, my username too and the username has the rights
            – Sulli
            Nov 10 at 20:23












            Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
            – Andrei Dumitrescu-Tudor
            Nov 10 at 20:25




            Is the mysql in the same container as wordpress? If so you cannot use localhost, you have to use the ip of the musql container.
            – Andrei Dumitrescu-Tudor
            Nov 10 at 20:25












            yes they are in the same container. You're saying I can not use localhost in this case?
            – Sulli
            Nov 10 at 20:42




            yes they are in the same container. You're saying I can not use localhost in this case?
            – Sulli
            Nov 10 at 20:42












            If they are in the same container you can use localhost. I mistyped before.
            – Andrei Dumitrescu-Tudor
            Nov 10 at 20:46




            If they are in the same container you can use localhost. I mistyped before.
            – Andrei Dumitrescu-Tudor
            Nov 10 at 20:46












            ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
            – Sulli
            Nov 10 at 21:04




            ah ok that's what I thought. I added the -p 4000:80 option for my docker and tried to access in my host's browser localhost:4000/phpmyadmin, but got the error "Access forbidden! New XAMPP security concept: Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf"." Is this related to my issue or is it only a because I'm accessing phpmyadmin from the host?
            – Sulli
            Nov 10 at 21:04












            up vote
            0
            down vote













            In wp-config.php, use 127.0.0.1 instead of localhost for the database hostname.






            share|improve this answer

























              up vote
              0
              down vote













              In wp-config.php, use 127.0.0.1 instead of localhost for the database hostname.






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                In wp-config.php, use 127.0.0.1 instead of localhost for the database hostname.






                share|improve this answer












                In wp-config.php, use 127.0.0.1 instead of localhost for the database hostname.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 at 21:40









                Sulli

                170218




                170218






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240752%2flocal-worpdress-website-can-not-connect-to-its-database%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Florida Star v. B. J. F.

                    Danny Elfman

                    Lugert, Oklahoma