Posted on

Move a mysql – mariadb database from one windows server to another windows server

Install xampp on the new server and If mysql is on, turn it off.

In the folder C: \ xampp \ mysql \ data create a new folder, for example with the name of the database you are moving.

Copy in it all the data files (.frm, .ibd, .myd, .myi) from the relative folder of the old server.

Make a copy in a backup folder of the file ib_logfile0, ib_logfile1, ibdata1 those are in the folder “C: \ xampp \ mysql \ data” in the new server.

Copy the files ib_logfile0, ib_logfile1, ibdata1 from the old server to the same location as the new server, i.e. in the folder C: \ xampp \ mysql \ data

Start mysql. Open a dos prompt, go to the directory

cd C: \ xampp \ mysql \ bin

mysql -u root -p

show databases;

You should see the new database added to the previous ones.

Open another dos prompt and check the tables with the commands

cd C: \ xampp \ mysql \ bin

mysqlcheck -uroot -p YOURDATABASE

Open your browser and connect to phpmyadmin with http: // localhost / phpmyadmin

You should see the database and tables.

Posted on

WordPress on Azure: Error establishing a database connection

You have a WordPress site hosted on Microsoft Azure.Perhaps your site is part of a free or shared app service plan.

Trying to connect to the site, one day, you have this wordpress error message:  Error establishing a database connection

How to find out and solve the problem?

Connecting  to Microsoft Azure Service with FTP

First of all you have to connect to the site via ftp to understand where the error is. We can connect to Azure web application with FTP also. In the Overview section of the your Azure web application, select “Get publish profile”. It will download a file that has a lot of things and teh details about FTP username and password, which is constant and can be used for FTP connection.

Enable WordPress Debug Logging

You need FTP connection to  enable WordPress Debug Logging. To enable error logging in WordPress, you will have to make both of the following changes :

  1. In wwwroot directory, create a file named .user.ini Add the following line:log_errors=on
  2. In wwwroot directory, open wp-config.php
    Add the following lines  :

//Enable WP_DEBUG mode
define('WP_DEBUG', true);

//Enable Debug Logging to /wp-content/debug.log
define('WP_DEBUG_LOG', true);

//Supress errors and warnings to screen
define('WP_DEBUG_DISPLAY', false);

//Supress PHP errors to screen
ini_set('display_errors', 0);

Also comment the line :

    /* define('WP_DEBUG', false); */

Analyze the Log File

Try to load your site. Now, through ftp, you can enter in the directoy LogFiles and analyze the file

php_errors.log

Database error

Perhaps you have a database error, for example a duplicate key problem. On azure, in your app service, select Mysql In -app button. On the top of the section, you can see the Manage button. Click on the button and you’ll load the phpMyAdmin portal on your local Mysql DB.

Duplicate entry

If you have this kind of error : Duplicate entry ‘XXXXX’ for key ‘PRIMARY’ for the  query INSERT INTO `table_name`, just ran following command :

REPAIR TABLE table_name

That’s it! It was done.