Results 1 to 10 of 10

Thread: MySQL Wordpress website on localhost - no content

  1. #1
    Join Date
    Mar 2009
    Location
    Lutsk, Ukraine
    Beans
    41
    Distro
    Ubuntu 10.10 Maverick Meerkat

    MySQL Wordpress website on localhost - no content

    Hello!

    I want to host my Wordpress site on my PC for sandbox editing. But the MySQL database seems to have errors when connecting localhost and the website database.

    I have installed Apache and Wordpress, as was shown in this guide:
    http://www.wpwebhost.com/install-wor...-lampp-server/

    This guide shows how to create a new Wordpress site with a clean MySQL database. Everything works well up unlit here - the dummy website displays on http://localhost/wordpress.

    When I try to import the .sql file downloaded from my website into MySql, it does not display any content. Perhaps I do not link the server and the database properly. Has anyone encountered a similar problem before?

    Also I apologize if I have posted in a wrong section.

  2. #2
    Join Date
    Feb 2008
    Beans
    Hidden!

    Re: MySQL Wordpress website on localhost - no content

    Quote Originally Posted by aryangor View Post
    ...When I try to import the .sql file downloaded from my website into MySql, it does not display any content. Perhaps I do not link the server and the database properly. Has anyone encountered a similar problem before?...
    Sorta remember WP likes hostname-based resolution, so, if the import.sql file came from domain.com and you want to import that into example.net, you may see an issue like this.

    How was this import done exactly?

    Code:
    mysql -uroot -p <db> < /path/to/file.sql
    check wp-config.php file on the server for MySQL username/password/db and substitute -uroot for the indicated user/pass/db in wp-config.php

    Connect with those credentials using a terminal >
    Code:
    mysql -u<user> -p
    and then
    Code:
    show databases;
    If your db does NOT show up, then you have a problem.

    Let us know....


  3. #3
    Join Date
    Mar 2009
    Location
    Lutsk, Ukraine
    Beans
    41
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Arrow Re: MySQL Wordpress website on localhost - no content

    Hey, thanks for your reply!

    Quote Originally Posted by Habitual View Post
    How was this import done exactly?

    Code:
    mysql -uroot -p <db> < /path/to/file.sql
    Yes, that's how I imported the .sql database file. If I log in as
    Code:
    mysql -uroot -p
    and view the list of databases, then the desired import.sql database is there on the list, along with the default wordpress.sql database.


    Quote Originally Posted by Habitual View Post
    check wp-config.php file on the server for MySQL username/password/db and substitute -uroot for the indicated user/pass/db in wp-config.php
    I have a feeling this is where the problem lies - here or with the database itself.

    Looking at wp-config.php, I find the following line:
    Code:
    define('DB_NAME', 'wordpress');
    
    /** MySQL database username */
    define('DB_USER', 'root');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'password');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    The DB_NAME value is 'wordpress' - this is the default one of the dummy Wordpress website, which is also an existing MySql database. When DB_NAME value is 'wordpress', my browser shows the dummy website at 'localhost/wordpress' just fine. When I change DB_NAME to 'import', as it appears on the list of databases, it takes me to my website on the web, and there it gives a 404 error.

    The name 'wordpress' in 'localhost/wordpress' is the name of the folder which apache2 reads, and it contains wp-config.php and other files that I downloaded from my website.

  4. #4
    Join Date
    Feb 2008
    Beans
    Hidden!

    Re: MySQL Wordpress website on localhost - no content

    Quote Originally Posted by aryangor View Post
    ...
    Code:
    define('DB_NAME', 'wordpress');
    
    /** MySQL database username */
    define('DB_USER', 'root');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'password');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    This is MOST insecure and NOT The Way.

    The DB_NAME value is 'wordpress' - this is the default one of the dummy

    Quote Originally Posted by aryangor View Post
    ...When I change DB_NAME to 'import'...
    why?

    typically, I'd create a wpinstall_user or some such with
    Code:
    mysql > create database mywp; 
    mysql > grant all privileges on mywp.* to wpinstaller@`localhost` identified by 'password'; 
    flush privileges; 
    exit;
    then test it with
    Code:
    mysql -uwpinstaller -p -e "show databases;"
    you should 'see' mywp

    use these for wp-config.php
    Code:
    define('DB_NAME', 'mywp');
    
    /** MySQL database username */
    define('DB_USER', 'wpinstaller');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'password');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');


  5. #5
    Join Date
    Mar 2009
    Location
    Lutsk, Ukraine
    Beans
    41
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: MySQL Wordpress website on localhost - no content

    Quote Originally Posted by Habitual View Post
    typically, I'd create a wpinstall_user or some such with
    Code:
    mysql > create database mywp; 
    mysql > grant all privileges on mywp.* to wpinstaller@`localhost` identified by 'password'; 
    flush privileges; 
    exit;
    then test it with
    Code:
    mysql -uwpinstaller -p -e "show databases;"
    you should 'see' mywp

    use these for wp-config.php
    Code:
    define('DB_NAME', 'mywp');
    
    /** MySQL database username */
    define('DB_USER', 'wpinstaller');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'password');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    Awesome, thanks for the tip! I did this the way you suggested.

    I have some progress now. localhost/mywp shows the website, but incompletely. Apparently, all plugins are there, but deactivated. And all pages, posts and widgets are not appearing.

  6. #6
    Join Date
    Mar 2009
    Location
    Lutsk, Ukraine
    Beans
    41
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: MySQL Wordpress website on localhost - no content

    Quote Originally Posted by aryangor View Post
    When I change DB_NAME to 'import', as it appears on the list of databases, it takes me to my website on the web, and there it gives a 404 error.
    I am back to this error. I don't understand why it takes me to www.mywebsite.com when I type localhost/database...

  7. #7
    Join Date
    Nov 2008
    Location
    BSAA Headquarters
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: MySQL Wordpress website on localhost - no content

    /methinks your wordpress URL is wrong in MySQL.

    Take a read of http://codex.wordpress.org/Changing_The_Site_URL

    I personally like the MySQL method (http://codex.wordpress.org/Changing_...n_the_database), but thats just me.

    Change the url to http://localhost/mywp
    Last edited by sandyd; August 31st, 2012 at 07:47 PM.
    Ubuntu Forums Moderation Staff || SandyDNET
    Twitter: @CatchesAStar | Last.fm
    Ubuntu Membership via Forum Contributions

  8. #8
    Join Date
    Feb 2008
    Beans
    Hidden!

    Re: MySQL Wordpress website on localhost - no content

    Quote Originally Posted by aryangor View Post
    I am back to this error. I don't understand why it takes me to www.mywebsite.com when I type localhost/database...
    as I said "if the import.sql file came from domain.com and you want to import that into example.net, you may see an issue like this."...

    Thanks sandyd!


  9. #9
    Join Date
    Mar 2009
    Location
    Lutsk, Ukraine
    Beans
    41
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: MySQL Wordpress website on localhost - no content

    Quote Originally Posted by sandyd View Post
    /methinks your wordpress URL is wrong in MySQL.

    Take a read of http://codex.wordpress.org/Changing_The_Site_URL

    I personally like the MySQL method (http://codex.wordpress.org/Changing_...n_the_database), but thats just me.

    Change the url to http://localhost/mywp
    Sorry about the late reply!

    Thanks, sandyd and Habitual! I have used the above-quoted link to change the URL and now everything works fine! Have a blesssed day!

  10. #10
    Join Date
    Feb 2008
    Beans
    Hidden!

    Re: MySQL Wordpress website on localhost - no content

    So glad you worked it out!

    Have a Great Day also!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •