[Repair] MySQL Upgrade on Mac OS X
The following are instructions to help you repair a MySQL upgrade after running the package-installer for a newer MySQL version.
These steps can also be followed before you install a new version, just leave out the steps for the 5.6 version.
Note: these instructions are for MyISAM files.
For InnoDB files, read this post before you do anything: Recovering an InnoDB table from only an .ibd file
Some of these instructions can also be used on CentOS, or maybe other flavours of Linux. But on those systems, it is common practice to remove the old version and install a new version via yum.
Tweet
1. Delete installation receipts:
$ su root
$ rm -rf /var/db/receipts/com.mysql.*
2. Delete current installations, except the one which /data-directory you want to keep:
$ cd /usr/local
$ ls -l
lrwxr-xr-x 1 root wheel 27 22 feb 10:30 mysql -> mysql-5.6.29-osx10.8-x86_64
drwxr-xr-x 4 root wheel 136 22 feb 14:08 mysql-5.1.37-osx10.5-x86
drwxr-xr-x 16 root wheel 544 22 feb 10:30 mysql-5.6.29-osx10.8-x86_64
3. In this case, the mysql-5.1.37-osx10.5-x86 folder contains all data, i.e. my databases.
Rename this folder to something like mysql_previous:
$ ls -l
lrwxr-xr-x 1 root wheel 27 22 feb 10:30 mysql -> mysql-5.6.29-osx10.8-x86_64
drwxr-xr-x 16 root wheel 544 22 feb 10:30 mysql-5.6.29-osx10.8-x86_64
drwxr-xr-x 4 root wheel 136 22 feb 14:08 mysql_previous
4. Remove the complete mysql instance and all other relevant files:
$ cd mysql-5.6.29-osx10.8-x86_64
$ rm -rf *
$ cd ..
$ rm mysql
$ rmdir mysql-5.6.29-osx10.8-x86_64
$ cd /Library/StartupItems/
$ rm -rf *MySQL*
$ cd /Library/PreferencePanes
$ rm -rf *MySQL*
$ vi /etc/hostconfig
[remove the line MYSQLCOM=….]
$ vi /Library/Receipts/InstallHistory.plist
[remove
<dict>
<key>date</key>
<date>2016-02-22T09:30:17Z</date>
<key>displayName</key>
<string>MySQL 5.6.29-community</string>
<key>displayVersion</key>
<string></string>
<key>packageIdentifiers</key>
<array>
<string>com.mysql.mysql</string>
<string>com.mysql.prefpane</string>
<string>com.mysql.launchd</string>
</array>
<key>processName</key>
<string>Installer</string>
</dict>
]
$ launchctl unload -w /Library/LaunchDaemons/com.mysql.mysql.plist
$ launchctl unload -w /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
$ ps -ef | grep -i mysql
0 20842 20833 0 8:14pm ttys000 0:00.00 grep -i mysql
$ cd /Library/LaunchDaemons/
$ ls -l *mysql*
-rw-r--r-- 1 root wheel 348 27 mei 2015 com.mysql.mysql.plist
-rw-r--r-- 1 root wheel 1370 15 jan 04:16 com.oracle.oss.mysql.mysqld.plist
$ rm -f *mysql*
$ cd /usr/local
$ vi copy_mysql_tables.sh
[change cq. add these copy commands:
cp -Rp mysql_previous/data/actman_pristine mysql/data/
cp -Rp mysql_previous/data/audi mysql/data/
cp -Rp mysql_previous/data/b1000 mysql/data/
cp -Rp mysql_previous/data/begeleider mysql/data/
cp -Rp mysql_previous/data/BSZBlogger mysql/data/
cp -Rp mysql_previous/data/bu2012 mysql/data/
cp -Rp mysql_previous/data/daimler mysql/data/
cp -Rp mysql_previous/data/fcs_rgl mysql/data
cp -Rp mysql_previous/data/fse_auth mysql/data/
cp -Rp mysql_previous/data/fse_dta mysql/data/
cp -Rp mysql_previous/data/fse_ttt mysql/data/
cp -Rp mysql_previous/data/fse_ttt_if mysql/data/
cp -Rp mysql_previous/data/handidate mysql/data/
cp -Rp mysql_previous/data/logdict mysql/data/
cp -Rp mysql_previous/data/lwa_fw mysql/data/
cp -Rp mysql_previous/data/proftpd mysql/data/
cp -Rp mysql_previous/data/sds82 mysql/data/
cp -Rp mysql_previous/data/tas mysql/data/
cp -Rp mysql_previous/data/wht mysql/data/
]
$ chmod a+x copy_mysql_tables.sh
$ cd /usr/local/lib/mysql
$ rm -rf *
$ cd ..
$ rmdir mysql
At this point, RESTART YOUR MAC
Install the new MySQL version
5. Download MySQL, for example the latest 5.6 and install.
6. Check if it is running via System Preferences -> MySQL (and eventually start it via this preference pane)
7. Start Navicat or MySQL Workbench and login with user root without password and then set the password. Logout and login again with password.
The tutorial on how to use Navicat : https://www.navicat.com/manual/online_manual/en/navicat/win_manual/
A good tutorial on how to use MySQL Workbench at MySQL : https://dev.mysql.com/doc/workbench/en/
8. Create the user lasso for both Lasso 8 and Lasso 9, and set passwords for other root-users
9.1 For MySQL 8.0.19 and earlier, do:
$ cd /usr/local
$ ./copy_mysql_tables.sh
$ mysql_upgrade -uroot -p --force
and restart MySQL.
9.2 For MySQL 8.0.20 and later, in case the new instance does not load the copied databases, add the following line to /etc/my.cnf:
secure_file_priv=''
Save, restart MySQL and enter MySQL's console:
$ mysql -u root -p
Then, for each database, execute the following command:
mysql> create database `<database name>` character set 'utf8' collate 'utf8_general_ci';
Query OK, 1 row affected (0.00 sec)
After this, all database directories will have been created under /usr/local/mysql/data/.
Stop MySQL, because this is the point where you can copy the tables into their database directories:
$ cd /usr/local
$ sudo ./copy_mysql_tables.sh
$ cd mysql
$ sudo chown -R _mysql:_mysql data/
Start MySQL, and enter MySQL's console and execute the following two commands for each database:
mysql> use <database name>;
Database changed
mysql> import table from '*.sdi';
Query OK, 0 rows affected (0.07 sec)
This will load each of your databases and all tables therein.
10) Start Navicat or MySQL Workbench and check if all databases show in localhost.
11) Now you can remove the previous MySQL version:
$ cd /usr/local/mysql_previous
$ rm -rf *
$ cd ..
$ rmdir mysql_previous
12) Check if both Lasso 8 and Lasso 9 have access:
- By running http://localuser/[webapp], or
- By checking in SiteAdmin (L8) and/or Lux (L9).
DONE