• Hi !

    I’m kinda new to this forum and to wordpress installations in general so please tell me if I made a mistake posting here ! Any help is appreciated.

    My situation :

    I decided a hour ago to turn an old desktop pc I found into a web server. I’ve followed a few tutorials and turned it into a Ubuntu “lamp-server”.

    I’m using Ubuntu 14.4, Apache 2 etc..

    Everything is working great and I decide to install wordpress, following this tutorial : LINK. I’ve followed all the steps as described but I end up having a problem when it comes to acceeding to wordpress through my browser.

    My problem :

    When i try to get to https://192.168.XX.XX/wp-admin/install.php I get an error message :

    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.

    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.

    So I checked my wp-config.php code, tried random inputs for database name etc… without success…

    Can anybody help me out ?

    I’m a newbie, so you would have to help me with commands etc…

    My site : LINK

    Thank you in advance !

Viewing 11 replies - 1 through 11 (of 11 total)
  • what database name did you input and what password?

    If you followed it to the letter you may have in your wp-config:

    database name: wordpress
    database user: root
    Database Password: password
    DBHost: localhost

    Thread Starter 42Fears

    (@42fears)

    Well, my password is obviously different. I didn’t use “root” as database user and I was ready to thank you for fixing my problem and pointing out how stupid my mistake was, but after modifying my file it still doesn’t work…

    No clue

    tried random inputs for database name etc… without success…

    There won’t be anything random about it. The username and password will be the exact username and password you created in MySQL and then assigned to your wordpress database. The database name will be the exact name of the database you created for your wordpress installation.

    Did you successfully give the database user you created permissions on the wordpress database?

    GRANT ALL PRIVILEGES ON your_databasename.* TO your_databaseusername@localhost;
    Thread Starter 42Fears

    (@42fears)

    Query OK, 0 rows affected (0.00 sec)

    So I guess yes, it was successful

    Thread Starter 42Fears

    (@42fears)

    I’ve tried it twice, by creating and deleting new databases. Maybe one of you could give me the whole process of correctly making a database for wordpress, if that’s where I made a mistake.

    Thread Starter 42Fears

    (@42fears)

    I feel like I’m giving you guys too few elements on how to help me. So here’s my wp-config.php :

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'wordpress');
    
    /** MySQL database username */
    define('DB_USER', '[removed]');
    
    /** MySQL database password */
    define('DB_PASSWORD', '[removed]');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');

    Maybe one of you could give me the whole process of correctly making a database for wordpress,

    If you’ve opted not to install phpMyAdmin – or if you’re using the Ubuntu server distro (without a desktop GUI):

    mysql -u root -p
    
    CREATE DATABASE wordpress;
    
    CREATE USER pete@localhost;
    
    SET PASSWORD FOR pete@localhost= PASSWORD("iampete");
    
    GRANT ALL PRIVILEGES ON wordpress.* TO pete@localhost IDENTIFIED BY 'iampete';
    
    FLUSH PRIVILEGES;

    In the above example my wordpress database name is “wordpress”, the database username is “pete”, and petes password is “iampete”.

    wp-config.php should look like this:

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'wordpress');
    
    /** MySQL database username */
    define('DB_USER', 'pete');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'iampete');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');

    Add the security keys – you can generate random keys here – https://api.www.ads-software.com/secret-key/1.1/salt/ – refresh the page to generate random keys.

    ..and I think that should do it.

    [edit] Some reference material that illustrates the process using several different database related tools: Step 2: Create the Database and a User

    Thread Starter 42Fears

    (@42fears)

    I didn’t have security keys until now. I’ve added those, however I still get the same error. My database configuration seems to be fine, I’ve followed the exact steps you describe here.

    Can a wrong security key cause this type of errors ? I’ve typed them manually so I can’t garantee that they are 100% the same as those of the page you gave me a link to.

    Is there a way to give an overview of my current setup so I can show it to you and maybe find what’s wrong ?

    I’ve been through the pages you added in your edit while trying to fix my problem, found nothing I might have done incorrectly.

    PS : This problem isn’t vital for me, I’m trying to set this up only for private fun, thank you very much for helping me, don’t feel like this is too important.

    Just a couple quick questions so I get a better idea of how you’re working with the OS:

    – Did you install the Server addition of Ubuntu, or are you working from the Desktop version

    -Did you at any point try installing WordPress from the Ubuntu Repo using “apt-get install wordpress” or by choosing it from the Ubuntu package manager?

    Thread Starter 42Fears

    (@42fears)

    I use Ubuntu server 14.04, I’m managing the server using SSH on my windows laptop.

    I’m not sure about the meaning of your second question.

    To get wordpress I used

    wget https://www.ads-software.com/latest.tar.gz

    extracted it etc…

    So I think my answer to your second question is no.

    It’s all good. “apt-get install wordpress” makes a mess. We can rule that out.

    A couple things you might try just to get a better idea of what’s going on. If you want to get a better visual reference of whats going on in the database, you can install phpmyadmin and you should probably be able to access it from the browser on your laptop with no issues.

    (sudo or sudo -i, your preference)

    you’ve probably already done this, but just in case:

    ~# /usr/bin/mysql_secure_installation

    Then to install phpMyAdmin

    ~# apt-get install php5-mcrypt phpmyadmin

    after the install, you will need to run

    ~# php5enmod mcrypt

    or else phpmyadmin will squawk about mcrypt not being installed, then run

    ~# service apache2 restart

    If your server is set up with a static private ip, you should probably be able to hit phpmyadmin with your laptop browser from 192.168.x.x/phpmyadmin

    See if you can log in as the root user, then see if you can log in as your wordpress database user. That might be revealing if both of those aren’t successful.

    If you don’t want to install phpmyadmin, you might open a putty (or whatever you use to connect) session and log into the server as your regular user account, then see if you can connect to mysql using your wordpress database user.

    A successful mysql connection as the user “pete” from my example earlier should look like this:

    pete@ubuntu:~$ mysql -u pete -p
    Enter password:
    
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 70
    Server version: 5.5.43-0ubuntu0.14.04.1 (Ubuntu)
    
    Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> show databases;
    
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | wordpress          |
    +--------------------+
    2 rows in set (0.00 sec)
    
    mysql>

    I hope that might help reveal something database or user related for you.

    [edit] .. I think an issue with keys might give you a blank page rather than a database connection message. I haven’t verified that, but I don’t believe that will cause the database error dialog.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Error establishing a database connection’ is closed to new replies.