Problems with moving my Wordpress site to another domain/server - sql

I'm having problems moving a wordpress site from one domain to another. I've searched the site but couldn find a useful answer for my situation.
Here's what i did:
I made a backup of the website. Then i exported the database.
Then i installed Wordpress on the other domain.
Then i copied all my Wordpress files of the old website on the new server overwriting the new installation. Then i deleted everything from the database on the new server and imported the database of the old server. Then i changed the database name and bpassword in the wp-config file.
So i did all this but the new site isn't working, and i don't know where it went wrong?
So i'd like to start over, but what should i do different?
Thankyou for your help!

You can run these sql queries in phpmyadmin to change URLs in the database after the move for site options, post URLs and URLs in post/page content:
UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');
4/22/2014 Edit: this is a much better solution that won't break PHP serialized data: interconnectit.com WordPress Serialized PHP Search Replace Tool

The main thing you need to do is update 2 fields in the database to the correct domain.
It can be done a few different ways.
Method 1:
Add this line to your wp-config.php file, then visit http://yournewdomain.com/wp-admin.php and log in. This will force the update:
define('RELOCATE',true);
After you log in, you should remove that line.
Method 2:
Add these 2 lines to your theme's functions.php file found at wp-content/themes/themename/functions.php
update_option('siteurl','http://example.com/blog');
update_option('home','http://example.com/blog');
After that, you need to update the GUID for each post. In phpMyAdmin or from the mysql command line issue this:
UPDATE wp_posts SET guid = REPLACE (
guid,
'http://exampleoldsiteurl.com',
'http://examplenewsiteurl.com');
replace exampleoldsite and examplenewsite with the respective domains.
All of this info can be found at http://codex.wordpress.org/Changing_The_Site_URL

You will probably need to edit some fields in your database and update the settings in the admin area. There is quite a nice guide here
http://codex.wordpress.org/Moving_WordPress#Moving_WordPress_to_a_New_Server
I think the easiest way is probably:
Install a new Wordpress blog
Go on old blog Admin panel. Here, in Manage > Export select "all" in menu
Restrict Author.
Click on Download Export File
In new blog go on Manage > Import, choose Wordpress item.
In the page that will be shown, select the file just exported. Click
Upload file and Import
It will appear a page. In Assign Authors, assign the author to users
that already exist or create new ones.
Click on Submit
At the end, click on Have fun

Instead of installing Wordpress on new server. Copy old files to new server, import database and change wp-config. I found this helpful How to Transfer a WordPress website to another Host

There is also a tool available for those who are not confident running SQL update scripts, found at:
Search and Replace for WordPress DB
Remember to delete files after performing the desired actions to the DB, because the script exposes DB username/password found in wp-config.php ;)

Related

How to disable all Comments in Wordpress?

I would like to disable all COMMENTS on my WordPress installation. From what I see I can disable only comments for new posts (in Setting), I can disable comments for posts (using Bulk Actions), but there is no bulk actions to disable comments for media files. I am not really interested in installing more plugins that could do it.
There should be one nice switch that would enable/disable all comments on WordPress. I am sure this can be done with SQL (either over shell or phpMyAdmin).
You can disable comments for existing posts using Bulk Edit, but this is not possible for existing media files. You can do both with a single SQL command (please verify wp_your_table_with_posts value to match your installation):
UPDATE wp_your_table_with_posts SET comment_status = 'closed';
You can disable comments for all new posts either by hand as administrator unchecking Settings / Discussion / Allow people to submit comments on new posts, or using SQL command (again, please verify wp_your_table_with_posts value to match your installation):
UPDATE wp_your_table_with_options SET option_value = NULL WHERE option_name = 'default_comment_status';

Automatically add database entry after ftp upload

Sorry if this seems stupid but I wonder if it's possible to add a database entry after an ftp upload.
To be more clear, thanks to winSCP I have several folders sending everything I put in there automatically to my server.
However, I would like to create a mysql entry for each uploaded files and once again, automatically. Is it possible to do that? How?
To gives the full details of what I need to do, you can read the following.
I have several folders with pictures and each folders are uploaded automatically.
Each of those folders belong to one user and the goal is to give them an account and allow them to see and download those files through a web interface. Since one account = one folder, that's kinda easy.
And I think a simple .htaccess can simply secure things so one user can only see and download the file in his own repository, no?
However if I want them to be able to see what's new (=something they didn't download or simply mark as read) I think I need a table to manage those files.
Something like id | file (string) | read (bool).
If you think this way to proceed is bad, they I'm open to change how to do things, but to be clear uploading the file need to work this way. Not using any kind of formulary.
Thanks for reading that, sorry for my english.
Your problem contains three steps:
Folders/Files been automatically uploaded to your server directory, as you say, this been efficiently handled by winSCP.
You need to update your database with all the files and folders present in your server directory.
You need to update whether or not it is been read/downloaded by the user.
Since your first step is in place, we don't need anything there. For second step, you should write a script and schedule that script to run at a fixed time interval using CRON (if using LINUX or UNIX, or WINDOWS). The script would be responsible to create a list of file(s) present in the directory, and simply insert the file(s) information that are not present in your database.
EDIT:
This edit is to describe how your script file should work. As I explained, the cron jobs would simply help you run your script file in fixed set of interval (which can be every minute, or every hour, or every day, and so on). Lets say your database table has following columns:
fileid (varchar[20])
filepath (varchar[20])
status (boolean)
Your script file should do following things:
Create a list of existing filepaths in your server directory
Run a select query, create a list of existing filepaths from database table.
Compare list1 with list2, and find the ones that doesn't exist in list2 (This would give you a list of filepath that needs to be inserted into table)
Just insert the list of file paths you got above, and set there status to be false (which means the file is not read/downloaded yet)
NOTE: Please keep in mind that I am not advising right now that how your database table should look like. It can be what you have proposed or can even differ depending on your will or requirements.
For the third step, simply keep the status of your file to be unread when creating entries in your table from the second step, and then when user click on the file link in your application whether to view or download it, send a POST request to your server updating the file status to be marked as read.
Let me know if this helps!

logrotate keep old file names

By default log rotate shifts file name's index on each rotation. I would like to keep names for old files. On each rotation: create new files + delete outdated.
Reason: every time I am rsycn those files with another sever, I have to download ALL file instead of simply downloading newly created ONE file and removing outdated ONE file.
Thanks
This web site and its users simply s#cks! This web site dedicated to newbie questions, which later will be replied by another group of newbies who will use google search to copy&paste reply (have no clue what they are saying) or by replying irrelevant clarification posts.

sql replace for wordpress database

I'm in the process of moving my wordpress installation over to a new server and a new domain. I have all the files moved over and I have a new database created and changed the settings in wp-config.php to reflect this. However, upon importing everything, it's still pointing to my previous domain. I'm looking to cut ALL ties to my previous domain, so I want to do an SQL query (through phpMyAdmin) to replace EVERY instance of my old domain and change them to my new domain.
I've stumbled upon the following:
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://oldlink.com', 'http://newlink.com');
I've tried replacing the wp_table instances with * and it throws a syntax error. Can any of you fine intelligent people help me out with altering this query? thanks!
Updating it via SQL will be way too much of a pain because ou have ~13 tables (more if you have plugins) each with many columns.
I have two ways of doing this
If you have plugins that created their own tabes:
Export the entiredatabase into a SQL File, open up in a text edior and do a find and replace on the following
oldomain.com/path/to/wordpressinstall
newdomain.com/path/to/install
Chances are you will just need olddomain.com and new domain.com without any sub folders. Its super important that you do not include anything such as http:// or www as well as any trailing slashes at the end. This will match 100% of the urls regardless of if they look like this:
http://domain.com/wp-content/lol.jpg
www.domain.com
www.domain.com/
Once you are done, delete your old DB and import this one.
If its just a simple wordpress install
Set the urls in your wp-config file:
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
Now that you have hard coded the site url you can log into your new site, download a plugin called search and replace and run the above search/replace with the nice GUI interface.

phpbb forum files deleted but database safe. how to configure new files with the existing database?

I have been using a phpbb forum.
It got deleted.
The database is intact. safe.
What are all the files i should modify.
I hope it is mostly one config file.
what are all the configurations i need to change?
so that the new files will work with the existing database.
I forgot the version. may be i can read it from the database.
Anyway... I need a help to restore my project.
If you have no files at all, the easiest way is to:
1 - download your database
2 - Create a new installation of Phpbb (easiest to use the same version you used to run)
3 - Once you have a new bare bones forum, log into Phpmyadmin, or whatever you use to manage databases, and drop all the tables from the new install, leaving a completely empty db.
4 - Import your saved DB to the empty database. This will restore all users and posts etc
5 - If your old forum used any mods you can either reinstall them (any db tables should still be there), or use the Support Toolkit (download from phpBB) and run the database cleaner. This will remove all non standard tables leaving your db as if it was a clean install but retaining all posts, users etc.
When I lost all my forums, I chose this route and cleaned the database. I then updated the forum to the latest version, and reinstalled all styles and mods from scratch. It's probably not the easiest way to do things, but I knew I had everything bug free, up to date, and no bits of unused mod cluttering the database.
First, you'll need the DB URL, (localhost) DB name,the user name and password for the database and the prefix for the tables. config example:
<?php
// phpBB 3.0.x auto-generated configuration file
// Do not change anything in this file!
$dbms = 'mysqli';
$dbhost = 'localhost';
$dbport = '';
$dbname = 'name_of_phpbb_db';
$dbuser = 'your_mysql_username';
$dbpasswd = 'your_mysql_pass';
$table_prefix = 'phpbb_';
$acm_type = 'file';
$load_extensions = '';
#define('PHPBB_INSTALLED', true);
// #define('DEBUG', true);
// #define('DEBUG_EXTRA', true);
Then you can delete or rename the install folder and go directly to your site. You'll have to tweak the DB in phpMyAdmin if you had a style other than default. and being your phpBB directory was gutted, all attachments, images, mod's and styles will be gone. You'll have to go into the modules_table in the DB and disable the non existent mods or you'll get errors in the ACP
I found out the answer from phpbb forum.
it worked.
Here it is...
http://www.phpbb.com/community/viewtopic.php?f=46&t=2110940&p=12899021#p12899021
:D
but still if people would like to comment or suggest then please do so.