Tuesday, May 3, 2022

Wordpress move errors and fixes

Export wordpress blog from one domain to another


1. To move a wordpress installation just go and archive the files where wordpress is installed and make it a zip archive as cpanel can extract only zip files.

2. Open phpMyAdmin and export the database to export_file.sql
You are done on the old server.

Login to cpanel on new server.
Go to File Manager upload and extract archive to public_folder.

Create a new database and a username and associate the username to the database.
Open phpMyAdmin select the created database and import the export_file.sql


Next we have to change Site URL and Home Settings to point to the new domain.
Select wp_options table and edit first two rows : siteurl and home to the new domain name.

Optional you can add to wp-config.php the lines instead of edition the wp_options table, but this will grey out the url option in wordpress admin so i suggest to use the database table edit.
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

Next edit wp-config.php and insert database name, username and password of the user associated to the database :

/** The name of the database for WordPress */
define('DB_NAME', 'database_name');

/** MySQL database username */
define('DB_USER', 'username');

/** MySQL database password */
define('DB_PASSWORD', '1234');

WP - Error establishing a database connection

Yousite.com/wp-admin/maint/repair.php


Press the Repair Database button:
The wp_options table is not okay. It is reporting the following error: Table is marked as crashed and last repair failed. WordPress will attempt to repair this table…

For this to work you must have this enabled:

 wp-config.php 

define('WP_ALLOW_REPAIR', true);

Also check in here that the corect database is selected, and you can also check with phpMyAdmin the database.

Fo security reasons you should disable it afterwards.

It can be done in multiple ways.

First is edit php.ini. Find error_reporting = E_ALL and add to it to look like this :
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

then restart apache server.

If this does not work you can always go to your wordpress installation and edit wp-config.php and add this :

ini_set('log_errors','On');
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);


instead of  :
define('WP_DEBUG', false);

Refresh the page where you got the warnings and enjoy. ;)