This document cover how to upgrade to the latest version available. There are currently three version of MySQL supported in portage:
There are two additional version presently, but are currently unsupported meaning that bug reports have very low priority any may lack functionalities. The current document is not guaranteed to work with them.
This step require to (re)move some files from the running environment, so the first thing to do is a backup of the running database server, still not the data. Done that, it's possible to remove the conflicting files with the slotted MySQL and install the new version side by side with the current one.
# quickpkg dev-db/mysql # rm -rf /usr/include/mysql /usr/bin/mysql_config # for tmpfile in /usr/lib/*mysql* ; do mv "${tmpfile}" "${tmpfile}.TMP" ln -s "${tmpfile}.TMP" "${tmpfile}" done # emerge -av =dev-db/mysql-5.0.18-r30
Be sure to update the
Lets go to to dump the data, this will be imported in the new version of MySQL.
We are going to use mysqldump from the slotted MySQL. Notice the
# mysqldump-500 \ --defaults-file=/etc/mysql/my.cnf -uroot \ --password='your_password' \ -hlocalhost \ --all-databases \ --opt \ --allow-keywords \ --flush-logs \ --hex-blob \ --master-data \ --max_allowed_packet=16M \ --quote-names \ --result-file=BACKUP_MYSQL_4.0.SQL
Now a file named
Start the server without networking and user management and run the SQL script:
# mv /etc/conf.d/mysql /etc/conf.d/mysql.orig # echo ' NOCHECK=1 DEBUG=3 mysql_slot_500=( "skip-networking" "skip-grant-tables" ) ' > /etc/conf.d/mysql # /etc/init.d/mysql-500 start # mysql-500 --defaults-file=/etc/mysql-500/my.cnf < BACKUP_MYSQL_4.0.SQL # mv /etc/conf.d/mysql.orig /etc/conf.d/mysql # /etc/init.d/mysql-500 stop
If you need to be sure that applications are working with the newly installed
server, please test them against it, quite every application has configuration
settings to chose which port or socket to use to connect to the database
server. Simply start the server on an alternate port (for example 3307) and tell
your application or a test copy of it to connect with those parameters. Pay
attention that most of them will try to use the parameters found in the
When you're satisfied with the results, remove every testing setting, stop the old server and start the new one. Also make it the server that will start at next reboot.
# rc-update del mysql default # rc-update add mysql-500 default # /etc/init.d/mysql stop # /etc/init.d/mysql-500 start
Unmerge the old version, and make the new one the default. The unmerge command
will be unable to remove some files, the ones moved in
# emerge --unmerge --pretend mysql # emerge --unmerge "=dev-db/mysql-4.0.26" # cd /etc # mv mysql mysql.$(date +%F_%H-%M) # rm -rf /usr/lib/*.TMP # rm -rf /usr/lib/*.TMP # for i in /usr/lib/*mysql* ; do readlink -f $i || [[ -L $i ]] && rm $i done # eselect mysql list # eselect mysql set 1 # eselect mysql show
After you got rid of your old MySQL installation, you can now install the new
version. Note that
# revdep-rebuild --soname libmysqlclient.so.12 -- -p -v # revdep-rebuild --soname libmysqlclient.so.12
# mysql_fix_privilege_tables-500 \ --defaults-file=/etc/mysql-500/my.cnf \ --user=root \ --password='your_password' # mysql -uroot -p'your_password' mysql -e "FLUSH PRIVILEGES;" # for tbl in $( mysql --silent -uroot -p'your_password' -e 'USE mysql ; SHOW TABLES LIKE "help%";' ) do mysql -uroot -p'your_password' -e "use mysql ; TRUNCATE TABLE ${tbl};" done # mysql -uroot -p'your_password' mysql < /usr/share/mysql/fill_help_tables.sql
If you encountered any problems during the upgrade process, please report them
at our