• Resolved Robert Trevellyan

    (@trevellyan)


    I’m attempting to migrate a site from a local build environment (MySQL 5.5.43) to a live server using Duplicator. I have done this successfully many times (thanks for the plugin!) Unfortunately the deployment is failing now because the older version of MySQL (5.1.56) on the hosting account doesn’t support utf8mb4_unicode_ci collation. I guess this has only just become an issue because earlier versions of WordPress didn’t make use of multibyte collation support.

    https://wordpress.org/plugins/duplicator/

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter Robert Trevellyan

    (@trevellyan)

    For anyone needing a workaround, you can run this php script on your existing installation before migration (posted on stackoverflow.com by hkasera):

    <?php
    $con = mysql_connect('localhost','user','password');
    if(!$con) { echo "Cannot connect to the database ";die();}
      mysql_select_db('dbname');
      $result=mysql_query('show tables');
      while($tables = mysql_fetch_array($result)) {
        foreach ($tables as $key => $value) {
          mysql_query("ALTER TABLE $value CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
        }}
      echo "The collation of your database has been successfully changed!";
      ?>

    Amazing thanks so much for this mate, helped me big time 🙂

    Thanks Trevellyan!

    I’ll see if I can integrate that as an option in the installer…

    Cheers~

    Thread Starter Robert Trevellyan

    (@trevellyan)

    That would be excellent, thanks!

    Marking as resolved…

    I can confirm resolved, from my point of view. After migration I tested plugin upgrades, page creations & removals. Even as of WP 4.2 it doesn’t care that the server doesn’t support utf8mb4_unicode_ci, even if it was installed on a server that supported it (I guess it fails back to utf8_unicode_ci).

    Thanks very much to Cory & Trevellyan, and I agree it would be vital for this to be the installer, even as an “advanced” option, since so many people will have to move development sites into production on brain-dead hosting.

    Thread Starter Robert Trevellyan

    (@trevellyan)

    In which version? I don’t see a release more recent than my report.

    This has not been applied to any Duplicator versions as of 0.5.18.

    @trevellyan you are genius thanks for the script…..really saved my life

    Thread Starter Robert Trevellyan

    (@trevellyan)

    You’re welcome, I copied it from hkasera’s answer to “How to change collation of database, table, column?” on stackoverflow.com.

    Beginner question: When you say “Run this script on your existing installation” do you mean go into phpMyadmin and run a query on the database? If not, where do you run the script from?

    Thanks!!

    Thread Starter Robert Trevellyan

    (@trevellyan)

    What this means is:

    1. Create a .php file and paste in the script.
    2. Edit the script to replace the placeholders with information specific to your server.
    3. Upload the script to your server.
    4. Enter the URL of the script in your browser to run it.
    5. Delete the script from your server.
    6. Use your favorite migration process to migrate your installation.

    I’m trying to deal with this issue now, and have a newbie question:

    When you say “Edit the script to replace the placeholders with information specific to your server.” exactly what does that mean? Which text items in the script are placeholders? Can you please point them out for me and the other newbies?

    Again, sorry for the newbie question and HOPEFULLY Duplicator will be updated soon so that this manual intervention with database issues is just a distant nightmare.

    Thread Starter Robert Trevellyan

    (@trevellyan)

    In this line:
    $con = mysql_connect('localhost','user','password');
    ‘localhost’, ‘user’ and ‘password’ are placeholders. You need to replace them with the correct hostname, user name and password for your MySQL server.

    In this line:
    mysql_select_db('dbname');
    ‘dbname’ is a placeholder. You need to replace it with the name of the database that you want to modify.

    All the values you need can be found in your wp-config.php.

    I’ve used code above on dev env, and then migrate to production env without errors. Everything works, but all text and symbols was replaced to �����. See https://yadi.sk/i/xmQCNpRzmfr8K

    UPD: original text was in russian

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘can Duplicator handle different collation methods between MySQL versions?’ is closed to new replies.