• I was able to download the site and import tables from the live site database. I want to be able to make changes as I please on the local copy, but after a few login errors I got locked out. I’m not sure. I think it was a plugin on the live site because I have to log in using my live site administrator account and password.

    I know I’m using the live site information on the database name, user and password. I know how to generate new secret keys, but I don’t dare do anything that may affect the live site.

    Can’t I just set up a different database name, username, and password to log in without using my live site credentials? I want to be able to change codes and setups, plugins, etc on my localhost installation.

    Is there some way I can do that? I’ve read a lot of articles and instructions on how to prepare your localhost for migration back up to your host, but that’s not what I’m interested in. If anything, I’d like to be able to put my localhost developed site on any host I should want to pick.

    Any help on this pleas? I’m not sure if this is a “support” question. I tried to describe what I see and what I want to fix.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter silvanet

    (@silvanet)

    The more I think about it, I didn’t really make myself as clear as I thought.
    1. I have duplicated my live site and imported the database to my localhost on XAMPP.
    2. When I created the localhost database, I kept my live site database name, user, and password. I don’t know if I could have done anything different. So, I edited the wp-config.php file to contain that information. I followed instructions to send a SQL query to update the links for the local site.
    3. in order to log in to wordpress on my localhost (to be able to open the dashboard & not just view the site), I had to use my live site login credentials.
    4. I don’t know if it was a plugin that did this, but after a few days of successfully checking my site settings and plugins on the localhost copy, I suddenly got an error referencing a file that mentioned an invalid DateInterval and referring me to an administrative email I hadn’t used in years for instructions on how to fix that.
    5. I figured something had locked me out. It’s all become a major pain.

    I wonder if there isn’t somewhere (like in the database) where I can change settings for my localhost site so nothing can be locking me out of logging in to my own local site. All I want to do is test and make changes on that localhost site independently of what is running on the live site that has been up for years. For now my thoughts on that one are if it ain’t broke don’t mess with it.

    When I get what I want on my localhost, I then want to be able to host it on any service I want, not just back to my original hosting service. I’m not too happy with the enormously long waiting periods to get technical support from them anyway, among other things.

    If anyone here knows WP well enough to guide me to how I might do what I”m asking, I’d be extremely thankful. I’m willing to read, study and learn, but I need to focus on the specific area of concern. Maybe I’m way off the wall here. Please let me know if that’s the case, too.

    This is the key part

    When I created the localhost database, I kept my live site database name, user, and password. I don’t know if I could have done anything different. So, I edited the wp-config.php file to contain that information. I followed instructions to send a SQL query to update the links for the local site.

    Since you are creating the database, you have the option to call it whatever you want, with whatever user and password you want. Those are then put into the wp-config.php file so that your site can work.
    What “instructions to send a SQL query” were you following? What was actually updated?

    in order to log in to wordpress on my localhost (to be able to open the dashboard & not just view the site), I had to use my live site login credentials.

    Yes, you copied the database, which contains the user table, so you have to use the same credentials. Once you are in, you can change password or add users.

    after a few days of successfully checking my site settings and plugins on the localhost copy, I suddenly got an error referencing a file that mentioned an invalid DateInterval and referring me to an administrative email I hadn’t used in years for instructions on how to fix that.

    If you keep the site open in your browser (I do this often on my test site), it will time out and make you log in again, but that’s not an error. WP doesn’t lock you out (but it only lets you in with the correct credentials). Since WP 5.2 though, there is a Recovery mode, so if a plugin or theme causes a fatal error, WP will send the admin email a special link(that expires) that will let you log in with the offending code paused, so you can address the issue.

    Thread Starter silvanet

    (@silvanet)

    Wow, thank you Joy!

    Yes, I’m using WP 5.1, so that Recovery mode is probably in effect. My problem is that the admin email I created several years ago hasn’t been used in forever. I don’t even know the password to it and haven’t been able to recover that because I don’t even know what the recovery email I used in setting it up was. I may just go back to scratch and re-import the live site backup that I made with Duplicator, this time paying attention to your explanation and renaming the database, changing the username and password from the start; and putting that into the wp-config.php file.

    The instruction in a couple of articles said to run this update query on my new localhost database (replacing https for http on live site if have SSL):

    UPDATE wp_options SET option_value = replace(option_value, ‘https://www.mylivesite.com’, ‘https://localhost/mysite’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
    UPDATE wp_posts SET post_content = replace(post_content, ‘https://www.mylivesite.com’, ‘https://localhost/mysite’);
    UPDATE wp_postmeta SET meta_value = replace(meta_value,’https://www.myylivesite.com’,’https://localhost/mysite’);

    Can I just change the username in the database’s user table, or do I have to use the livesite’s user and then change the password after I get in?

    I think if I have a step by step plan that covers all the exact things I should be doing, a new attempt may work better.

    I notices something else I don’t understand. From the WP Dashboard, while I also had phpMyAdmin open and could check my User in the localhost database, I went to Users and saw me as Administrator with a series of Profile settings. I changed some of the fields in the Dashboard and noticed they also changed in the database, but when I generated a new password I got a long password but the one in the database was not remotely the same. I tried it again and a different password is being returned back to the database than the one I generated. Is that normal? What is that password about?

    When using my manual installation of XAMPP, I got used to seeing the different sites served being in separate directories (folders). When I typed localhost I’d get teh XAMPP default Apache page. Then /anything/ would give me the sites in folders in the xampp/hddocs – mysitenames. Bitnami Apache installation seems to be serving out of their apps folder (where they have bitnami, phpmyadmin, and wordpress folders). Then in each they bury htdoc folders one, or two folders down to their file locations.

    And I notice that for some reason Bitnami’s server is running significantly slower than my XAMPP Apache installation does on port 80. I don’t have it running as a service and I turn it off when I’m using Bitnami. Especially when it runs phpMyAdmin, it takes forever.

    Yes, I’m using WP 5.1, so that Recovery mode is probably in effect.

    Well, no, Recovery mode is in 5.2+, but you might have mistyped 5.5.1 ?

    the admin email I created several years ago hasn’t been used in forever

    It’s a local site; just change it in the database.

    renaming the database, changing the username and password from the start; and putting that into the wp-config.php file.

    Only if you mean the database user and password, and not the WP user and password.

    The query that you show has some formatting problems. Hopefully you didn’t use it as I see it (with &#8217). Usually if you use a plugin for migrating your site, the plugin does the change for you. Trying to do it yourself like that can really mess things up, because there are serialized entries and you could have installed in a folder. I would use either a Search/Replace plugin or a migration plugin that makes the change.

    Can I just change the username in the database’s user table, or do I have to use the livesite’s user and then change the password after I get in?

    It’s better to use the live site’s user for two reasons. One, is that there is a special thing with user names. It is used as a prefix in the meta for the capabilities. Two, when you move your site back to live, you will have the same “situation” in the opposite direction, with the user table copied back to the live site, unless you choose not to move that table back.

    The password is not stored in plain text. WordPress doesn’t even know your password. As soon as you set your password, it is hashed and the hash is saved, so that anyone hacking in can’t know your password either. In order to log in, WP hashes what you enter and sees if it matches.

    When using my manual installation of XAMPP, I got used to seeing the different sites served being in separate directories

    I use my XAMPP this way also(I have about 10 local right now), and often put WP in a subfolder. In order to upgrade PHP, I tried with Bitnami, but not only was it a larger package, but I couldn’t get it configured or understand how to start and stop it, so I deleted it and went back to XAMPP, newer version. Use the tools how they make sense for you.

    • This reply was modified 4 years, 1 month ago by Joy. Reason: fixed entity
    Thread Starter silvanet

    (@silvanet)

    Sorry, I didn’t pay attention to what happened when I just cut and pasted the query. That &#8217 was not in the text I copied. I also tried the plugin approach and that didn’t work. So, my second attempt was to follow instructions on manually copying the files using FTP or host site cpanel file manager. Those were the instructions with the query. One of them was wpbeginner.com.

    I have no interest whatsoever in moving a site “back.” What I want to do is my development in a localhost, then put it on a hosting site of my choice. Once I put it on hosting I might consider a staging copy on the host. So, is it then pretty much impossible to make changes on a localhost and then upload to a hosting site? Won’t my localhost created database keep all my settings, plugins, etc.?

    I can understand that all the administrative settings should follow with the database. So why isn’t it just made clear that if you upload you will be overwriting all settings on the live site? I don’t get why database and site content aren’t just one package. You set whatever you want in the development stage on a local machine. You build and optimize it. Then upload it to a host.

    Thanks for the explanation on the password. That makes sense. I didn’t think of it, but looking at that hash in the database confused me. I was thinking it was just a strong password created by the password generator button in wp Dashboard User section. What is that pw related to? Is it a hash for the wp login pw or the database user pw? There are so many passwords it’s mind-boggling.

    Thanks. I was going batty with Bitnami. I”m also going back to XAMPP. Since I at least have the wordpess localhost site working in the bitnami build, I want to be careful to copy it over to my manual XAMPP installation and make the necessary configuration changes, or is that not advisable and I should do the whole process all over again?

    To avoid the problems I had the first time, should I use a plugin like Duplicator after creating a new administrator user in the site that I’ll use in the localhost copy. Can I create two administrators? I’ll then delete that user in the live site and keep my original administrator user. In the localhost database users table, I’ll delete my live site’s original one.

    You sure know how to pack questions into a small space…

    I also tried the plugin approach and that didn’t work.

    It depends on the plugin. There are some with thousands of users, so I’m sure they work. But it might be doing something different than you intend.
    I mentioned why you shouldn’t try to do the SQL method yourself, as it seems you don’t have the background to see the pitfalls. Unless your live site name is exactly the same number of characters as your local site name, you can mess up serialized data, which could be in the options table and meta table. So it really is better for the migration plugin to do the change for you.

    I don’t get why database and site content aren’t just one package.

    A site consists of files and database. Files are the WP software, plugins, themes, and uploaded images, but also the database export. You can’t really move the database directly. You have to export and import. The database itself is multiple tables: options, user, posts, taxonomies. They refer to each other, mostly using ID numbers. So each post entry contains an author ID and a featured image ID and a category ID.

    I have no interest whatsoever in moving a site “back.”

    You want to put it somewhere, though. It doesn’t matter where, it will be the same process as moving it from live to local. You have to change the URLs so the live site will work right. That’s why using a plugin is appealing. They’ve already figured out how to do it correctly. All you need to do is use it.
    The plugins usually make one big zip file, which can be problematic if you have a limited bandwidth like I have. So I usually do my own moves, like exporting the database myself and making the URL change. I install the software separately so I don’t have to download or upload a huge zip, since the images and stuff don’t really need to be involved. It just depends on what you are doing, and how much you know. But yes, your localhost database will have all the new settings you create, so you should keep it all together instead of only changing out some tables.

    What is that pw related to? Is it a hash for the wp login pw or the database user pw?

    The password in the user table of the database is a hash of the one you need to type in to log into the admin. It’s that user’s WP password (hashed). The database password is in the wp-config.php file. WP uses that to do everything it does with the database, for all requests.

    Since I at least have the wordpess localhost site working in the bitnami build, I want to be careful to copy it over to my manual XAMPP installation

    You can try it, but database files are not easy to move without messing up the index. I had my test site open when I knocked my laptop battery out one time, and the tables were corrupted. I had to start over. And when I moved from Ubuntu 16.04 to 20.04, I had to export and import instead of just moving the files.

    To avoid the problems I had the first time, should I use a plugin like Duplicator after creating a new administrator user in the site that I’ll use in the localhost copy.

    Yes, you can search for migration plugins if Duplicator is not working for you. There are several choices.

    Can I create two administrators? I’ll then delete that user in the live site and keep my original administrator user.

    You can create as many as you want, but can only use an email address once.

    Thread Starter silvanet

    (@silvanet)

    I certainly don’t have much background on WP. I don’t use it much. It’s easy enough to set up, has way too many themes and plugins. I know it’s super popular, but the minute you build a site you’re spammed with people selling their expert services. Maybe it’s like Microsoft, because the largest are the most hated, but I’ve seldom seen a platform more hacked than WP.

    I do have years of experience working back-ends and pretty good JavaScript & other basic programming experience with a couple of reputable long full-stack courses behind me. I’m familiar enough with coding and used to work Relational databases with lots of SQL many years ago. I’ve set up a pretty large number of working servers on local machines.

    No matter how much I’ve learned, I always spend a lot of time on forums like StackOverflow, and that’s also why I’m here. I saw a quote recently “Programming isn’t about what you know. It’s about what you can figure out.” – Chris Pine. It’s pretty much the same for everything you do. I really appreciate your sharing, advice, and communication.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Make localhost copy independent of live site?’ is closed to new replies.