WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] sandbox blog on localhost - howto (11 posts)

  1. beaniecopter
    Member
    Posted 7 years ago #

    I am trying to create a "sandbox" blog on my desktop, for experimentation before I upload new themes to my commercially-hosted web site. I have installed apache and mysql and wordpress 2.0, and have created a local database ("wordpress"). Everything appears to be working properly.

    I used mysqladmin to backup the database ("bc_wordpress") of the blog which is on-line. But after repeated attempts, I have hand no success in using mysqladmin to restore "wordpress" from "bc_wordpress". When I view the blog, I see only the greeting page which is shipped with wordpress 2.0.

    I am running a recent installation of Debian "testing" on a Pentium system.

  2. whooami
    Member
    Posted 7 years ago #

    if you are sure you imported the tables from the hosted site into your local site -- and youre not seeing the posts that you ought to, then I would guess you havent edited wp-config.php to reflect the necessary changes.

    Unless im not understanding you.

    Make sure youve edited this line in your local config, to reflect the proper prefix

    $table_prefix = 'wp_'; // Only numbers, letters, and underscores please!

    Looks like yours would be bc_

  3. beaniecopter
    Member
    Posted 7 years ago #

    I edited wp-config.php, and it reads correctly. I'm wondering whether the problem is in my attempt to restore database "bc_wordpress" from database "wordpress". That is, given a new, empty (local) database "wordpress", I am trying to make it a clone of the existing (remote) data base "wordpress". But this is mainly to have familiar postings with which to experiment.

    Perhaps I simply should give both databases the same name; then restoration from the backup should not be a problem, right? However, after I tinker a while with the local WordPress installation, the databases are going to be different, and it would be nice to give each a distinct name.

  4. whooami
    Member
    Posted 7 years ago #

    im sorry, im confused.

    what is the name of the database on the remote site? :

    what is the name of the database on the local site?

    More importantly, do the tables on both sites have the same prefix?

    Have you successfully imported the tables from your remotely hosted database into your local mysql install?

    --

    Youre making this harder than it needs to be. You do not need to import your remote database, you import the tables that exist within it.

    Get a mysql dump of all the tables on the remote server. Import them into ANY empty database, for simplicities sake and to not have to edit the .sql, name the local database the same as the remote one.

    Once you have imported the tables, you can rename the local database to anything you want.

  5. beaniecopter
    Member
    Posted 7 years ago #

    Thanks for your interest and patience!

    (1) Existing remote database is "bc_wordpress". New local database is "wordpress". (For the purpose of discussion, I should have called them, respectively, "remote" and "local".) In any case, the remote database has a prefix, but the local database does not.

    However, prefixes are irrelevant in this case, are they not? That is, could I not name the databases "remote_wordpress" and "local_wordpress"?

    (2) Forgive me, but I do not understand what you mean by "importing the tables from the remotely-hosted database into the local mysql install".

    The blog has been running on the remote host for about a year now. During that time, I have been using "mysql admin" to back up the remote data base.

    When I log into "mysql admin", I am able to see the backup of the remote data base as one of the "catalogs", but I don't know how to proceed. I have been trying -- without success -- to use the "restore backup" function.

    (3) I think that you are telling me that mysql (or perphaps mysqladmin) has the ability to copy tables from one database to another. I have tried the various menus, but I have not discovered how to do this.

    (4) Also I have not discovered how to rename a data base using mysql or mysql admin.

  6. whooami
    Member
    Posted 7 years ago #

    (1) Existing remote database is "bc_wordpress". New local database is "wordpress". (For the purpose of discussion, I should have called them, respectively, "remote" and "local".) In any case, the remote database has a prefix, but the local database does not.

    However, prefixes are irrelevant in this case, are they not? That is, could I not name the databases "remote_wordpress" and "local_wordpress"?

    Thats correct, the prefixes are irrelevent.They only matter when it comes to setting up wp-config, and thats for the tables.

    (2) Forgive me, but I do not understand what you mean by "importing the tables from the remotely-hosted database into the local mysql install".

    The blog has been running on the remote host for about a year now. During that time, I have been using "mysql admin" to back up the remote data base.

    When I log into "mysql admin", I am able to see the backup of the remote data base as one of the "catalogs", but I don't know how to proceed. I have been trying -- without success -- to use the "restore backup" function.

    If you are talking about this mysql admin:
    http://dev.mysql.com/doc/administrator/en/mysql-administrator-backup-advanced-options-execution-method.html
    then it clearly allows you to backup the tables. You do understand that the tables within the database are the important thing, yes? (im asking that question in all sincererity, not to somehow mock you)

    (3) I think that you are telling me that mysql (or perphaps mysqladmin) has the ability to copy tables from one database to another. I have tried the various menus, but I have not discovered how to do this.

    To reiterate, you need to export the tables from the remote database and import them into your local database. If you cannot accomplish that using mysql admin, I reccomend the mysql> command line or phpmyadmin.

    (4) Also I have not discovered how to rename a data base using mysql or mysql admin.

    Your root on your local box, you can do anything.

    http://www.phpmyadmin.net/home_page/index.php
    http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html

    the second link assumes you have shell access, IF you have shell access you should be able to connect to mysql and perform anything you have permissions for using any other application.

  7. whooami
    Member
    Posted 7 years ago #

    by the way, that mysql admin is just the normal shell command line tool for mysql, right, or not? Now that I realize that, check out that last link. Theres the missing piece to the puzzle.

  8. beaniecopter
    Member
    Posted 7 years ago #

    Thanks for the reply. At this point, I suppose that I need to do a bit of reading. And I need to explore my drive.

    The database backup has been one large file which "mysql admin" has deposited on my drive and which I dutifully have tucked away in a safe place, but I never have looked inside it, because I never before now had the need to use the backup. I wasn't thinking in terms of tables; I saw it only as a monolith.

    I never have run "mysql-administrator-backup"; I have have been using "My SQL Administrator" version 1.1.10, which has a GUI. Once I launch this application and log onto the server, I use the menus to select "backup".

  9. whooami
    Member
    Posted 7 years ago #

    dont sweat it, the backup is actually just a text file, chock full of things like:

    --
    -- Table structure for table
    blahblah
    --
    DROP TABLE IF EXISTS blahblah;
    CREATE TABLE blahblah ( ...

    .. and some other stuff. If you have that already, you can simply import it into your local database. Youre more than 1/2 way there :)

  10. beaniecopter
    Member
    Posted 7 years ago #

    The problem is solved; it turned out to be a matter of MySQL permissions. For the benefit of anyone else who has experienced similar difficulty, here is what I found and where I found it:

    (1) The best general guide which I found was "WordPress on Debian Linux", which is posted at:

    http://www.supriyadisw.net/2006/08/wordpress-on-debian-linux

    This article provides a step-by-step procedure for setting up Apache, with only a couple of minor typographical errors, and a couple of omissions, namely: install "libapache2-mod-php4" rather than "php4", and "php4-mysql" is needed in addition to "php4-pgsql". However, I had only limited sucess with the procedures which are specific to setting up and configuring MySQL.

    (2) The best detailed guide which I found was "DJG's Setting up MySQL users and databases", November 25th, 1999, which is posted at:

    http://www.linuxhelp.net/guides/mysql/

    (3) I discovered an EXCELLENT tutorial regarding MySQL permissions, "An Introduction to MySQL permissions", February 17, 2004, which is posted at:

    http://www.databasejournal.com/features/mysql/article.php/3311731

    The only things which the article failed to mention is the need for the command "use mysql;" at the first "mysql>" prompt. Also, the example commands twice omit the semicolon (";") which is required at the end of each MySQL command.

    (4) I found helpful the MAN pages for "mysql", "mysqladmin", and "mysqldump". In particular, the MAN page for "mysqldump", at the end, provides examples of useful applications for the utility.

    (5) I finally realized that life is too short to fool around with a graphical user interface (GUI) application for routine or repetive tasks such as daily or weekly backup of a database, if there exists a command-line interface which can handle the task. So, rather than continue using "mysql administrator", I have switched to "mysqldump", which is INFINITELY more simple, and which can be invoked by "cron" or "anacron".

    (6) I used the following commands to set permissions:

    # mysqladmin -u root -p

    << mysqladmin prompts for local_database_administrative_password. >>

    mysql> USE mysql;

    mysql> GRANT all ON local_database_name.*
    TO local_database_username@localhost
    IDENTIFIED BY 'local_database_user_password';

    mysql> QUIT

    # mysqladmin -u root -p reload

    (7) It turns out that, once the permissions are properly set, retrieving a copy of the database tables from the on-line, commercially-hosted blog required only the following command:

    $ mysqldump
    -h URL_of_remote_commercial_blog_host
    -u remote_database_username
    -premote_database_password
    remote_database_name > name_of_copy.sql

    And it turns out that loading a copy of the tables into the local "sandbox" blog required only the following command:

    $ mysql -h localhost
    -u local_database_username
    -plocal_database_password
    local_database_name < name_of_copy.sql

    In the above commands, note that:

    -> "$" is the terminal command prompt for a normal user.

    -> Each command must be entered as a single line.

    -> No space is permitted following the "-p" options.

    -> The "-p" option does not provide security for the password.

    -> The name of the ".sql" file created by mysqldump ("name_of_copy.sql") is arbitrary, including the ".sql" suffix.

    -> The user must substitute the actual names for:
    "local_database_administrative_password"
    "local_database_username"
    "local_database_user_password"
    "local_database_name"
    "URL_of_remote_commercial_blog_host"
    "remote_database_username"
    "remote_database_password"
    "remote_database_name"
    "name_of_copy"

    (8) Please note that some people use the term "sandbox" for a "static" blog, in order to experiment with themes and stylesheet without the complexity of running a database on the local host. But I am using the term "sandbox" for a fully-functional "dynamic" blog on the local host which allows me to exercise the blog normally, in every respect. If I desired, I could use my desktop machine to serve this blog to the Internet.

    RLH
    28 August 2006

  11. whooami
    Member
    Posted 7 years ago #

    :)

Topic Closed

This topic has been closed to new replies.

About this Topic