1

I am trying to migrate an old Windows Server 2003 32-bit machine, running MySQL 4.1, to a new Windows Server 2008 R2 64-bit machine, running MySQL 5.1, and have just got to the database part. I have quite a heavy DB sitting on the old server, and before I try to download the tables and then re-upload them to the new site, I want to make sure I don't have to do a conversion first? The old server is not running the latest MySQL or PHP so using PhpMyAdmin is out of the question, and I don't have permsission to change anything like that, I just have a rubbish, basic, buggy WebFusion control panel.

Any help gratefully appreciated.

5
  • The OS upgrade should be negligible (although you should doublecheck.) The much bigger difference will be the versions of MySQL. Are you changing versions, and if so, from what to what?
    – mfinni
    Jul 16, 2012 at 16:01
  • @mfinni: 4.1 to 5.1 (ish) Jul 16, 2012 at 16:05
  • 1
    You should add that info as an edit to your question, because it's much more relevant than the OS version incrementing.
    – mfinni
    Jul 16, 2012 at 16:13
  • About the only thing that might be relevant for the OS would be if the old server was x86 or x64, depending on how you're going to do your export/import or backup/restore. That could be a big deal, but again, not because of the version of the OS changing.
    – mfinni
    Jul 16, 2012 at 16:14
  • @mfinni: Edits made, thanks. Old server is 32-bit and new server is 64-bit. Jul 16, 2012 at 16:18

2 Answers 2

4

You should mysqldump the entire mysql database into a textfile because a mysqldump is a logical representation of the data. This may avoid any problem that can occur jumping between major releases. There is one major concern: the mysql schema,

Step 01) MySQL

C:\> mkdir C:\>MySQLData
C:\> mysql -h... -u... -p... --all-databases > C:\MySQLData\MySQLDataDump.sql

Step 02) Install MySQL 5.5 on Win2008

Step 04) Copy the my.ini of MySQL 4.1 over to Win2008

Step 05) Reload C:\MySQLData\MySQLDataDump.sql back into MySQL 5.5

mysql < C:\MySQLData\MySQLDataDump.sql

Step 06) Run mysql_upgrade.exe

This is where things can go a little nuts because This is what the mysql schema looks like in MySQL 4.1.22

mysql> use mysql
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| func                      |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
15 rows in set (0.00 sec)

mysql> desc mysql.user;
+-----------------------+-----------------------------------+------+-----+---------+-------+
| Field                 | Type                              | Null | Key | Default | Extra |
+-----------------------+-----------------------------------+------+-----+---------+-------+
| Host                  | varchar(60)                       |      | PRI |         |       |
| User                  | varchar(16)                       |      | PRI |         |       |
| Password              | varchar(41)                       |      |     |         |       |
| Select_priv           | enum('N','Y')                     |      |     | N       |       |
| Insert_priv           | enum('N','Y')                     |      |     | N       |       |
| Update_priv           | enum('N','Y')                     |      |     | N       |       |
| Delete_priv           | enum('N','Y')                     |      |     | N       |       |
| Create_priv           | enum('N','Y')                     |      |     | N       |       |
| Drop_priv             | enum('N','Y')                     |      |     | N       |       |
| Reload_priv           | enum('N','Y')                     |      |     | N       |       |
| Shutdown_priv         | enum('N','Y')                     |      |     | N       |       |
| Process_priv          | enum('N','Y')                     |      |     | N       |       |
| File_priv             | enum('N','Y')                     |      |     | N       |       |
| Grant_priv            | enum('N','Y')                     |      |     | N       |       |
| References_priv       | enum('N','Y')                     |      |     | N       |       |
| Index_priv            | enum('N','Y')                     |      |     | N       |       |
| Alter_priv            | enum('N','Y')                     |      |     | N       |       |
| Show_db_priv          | enum('N','Y')                     |      |     | N       |       |
| Super_priv            | enum('N','Y')                     |      |     | N       |       |
| Create_tmp_table_priv | enum('N','Y')                     |      |     | N       |       |
| Lock_tables_priv      | enum('N','Y')                     |      |     | N       |       |
| Execute_priv          | enum('N','Y')                     |      |     | N       |       |
| Repl_slave_priv       | enum('N','Y')                     |      |     | N       |       |
| Repl_client_priv      | enum('N','Y')                     |      |     | N       |       |
| ssl_type              | enum('','ANY','X509','SPECIFIED') |      |     |         |       |
| ssl_cipher            | blob                              |      |     |         |       |
| x509_issuer           | blob                              |      |     |         |       |
| x509_subject          | blob                              |      |     |         |       |
| max_questions         | int(11) unsigned                  |      |     | 0       |       |
| max_updates           | int(11) unsigned                  |      |     | 0       |       |
| max_connections       | int(11) unsigned                  |      |     | 0       |       |
+-----------------------+-----------------------------------+------+-----+---------+-------+
31 rows in set (0.00 sec)

mysql>

Here is what the mysql schema looks like in MySQL 5.5

mysql> use mysql
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| audit_user_host           |
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| slow_queries              |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
26 rows in set (0.07 sec)

mysql> desc mysql.user;
+------------------------+-----------------------------------+------+-----+---------+-------+
| Field                  | Type                              | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+---------+-------+
| Host                   | char(60)                          | NO   | PRI |         |       |
| User                   | char(16)                          | NO   | PRI |         |       |
| Password               | char(41)                          | NO   |     |         |       |
| Select_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Insert_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Update_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Delete_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Create_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Drop_priv              | enum('N','Y')                     | NO   |     | N       |       |
| Reload_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Shutdown_priv          | enum('N','Y')                     | NO   |     | N       |       |
| Process_priv           | enum('N','Y')                     | NO   |     | N       |       |
| File_priv              | enum('N','Y')                     | NO   |     | N       |       |
| Grant_priv             | enum('N','Y')                     | NO   |     | N       |       |
| References_priv        | enum('N','Y')                     | NO   |     | N       |       |
| Index_priv             | enum('N','Y')                     | NO   |     | N       |       |
| Alter_priv             | enum('N','Y')                     | NO   |     | N       |       |
| Show_db_priv           | enum('N','Y')                     | NO   |     | N       |       |
| Super_priv             | enum('N','Y')                     | NO   |     | N       |       |
| Create_tmp_table_priv  | enum('N','Y')                     | NO   |     | N       |       |
| Lock_tables_priv       | enum('N','Y')                     | NO   |     | N       |       |
| Execute_priv           | enum('N','Y')                     | NO   |     | N       |       |
| Repl_slave_priv        | enum('N','Y')                     | NO   |     | N       |       |
| Repl_client_priv       | enum('N','Y')                     | NO   |     | N       |       |
| Create_view_priv       | enum('N','Y')                     | NO   |     | N       |       |
| Show_view_priv         | enum('N','Y')                     | NO   |     | N       |       |
| Create_routine_priv    | enum('N','Y')                     | NO   |     | N       |       |
| Alter_routine_priv     | enum('N','Y')                     | NO   |     | N       |       |
| Create_user_priv       | enum('N','Y')                     | NO   |     | N       |       |
| Event_priv             | enum('N','Y')                     | NO   |     | N       |       |
| Trigger_priv           | enum('N','Y')                     | NO   |     | N       |       |
| Create_tablespace_priv | enum('N','Y')                     | NO   |     | N       |       |
| ssl_type               | enum('','ANY','X509','SPECIFIED') | NO   |     |         |       |
| ssl_cipher             | blob                              | NO   |     | NULL    |       |
| x509_issuer            | blob                              | NO   |     | NULL    |       |
| x509_subject           | blob                              | NO   |     | NULL    |       |
| max_questions          | int(11) unsigned                  | NO   |     | 0       |       |
| max_updates            | int(11) unsigned                  | NO   |     | 0       |       |
| max_connections        | int(11) unsigned                  | NO   |     | 0       |       |
| max_user_connections   | int(11) unsigned                  | NO   |     | 0       |       |
| plugin                 | char(60)                          | NO   |     |         |       |
| authentication_string  | text                              | NO   |     | NULL    |       |
+------------------------+-----------------------------------+------+-----+---------+-------+
42 rows in set (0.03 sec)

mysql>

Major difference, eh ??? This is why regardless of whether you copy the data folder or freshly load a mysqldump, you run mysql_upgrade.exe afterwards to add the appropriate columns and tables.

As an alternative, you could just mysqldump each database separately from MySQL 4.1 and import each mysqldump into MySQL 5.5. So, what about the GRANTS? Try converting the GRANTS in MySQl 4.1 into pure SQL.

MYSQL_USERNAME=...
MYSQL_PASSWORD=...
MYSQL_CONN="-u${MYSQL_USERNAME} -p${MYSQL_PASSWORD}"
mysql ${MYSQL_CONN} --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user WHERE user<>''" | mysql ${MYSQL_CONN} --skip-column-names -A > C:\TMP\MySQLUserGrants.sql

This will produce SQL Commands to reproduce User Grants into any version of MySQL 4.1+

Import that file in MySQL 5.5 and you should be good from there.

1

If you're planning to copy MySQL's raw data files, I'd recommend against that.

However, if you dump the tables in MySQL 4 using mysqldump or mysqlhotcopy and import them into MySQL 5, everything should work just fine. mysqldump creates an SQL script with all of the SQL commands (such as CREATE TABLE and INSERT) necessary to reconstruct the same database in a new MySQL instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.