{"id":929,"date":"2015-07-30T17:45:38","date_gmt":"2015-07-30T20:45:38","guid":{"rendered":"http:\/\/blog.abratel.com.br\/?p=929"},"modified":"2015-07-30T17:49:26","modified_gmt":"2015-07-30T20:49:26","slug":"upgrading-mysql-5-0-ou-5-1-to-5-5-ou-5-6-on-freebsd","status":"publish","type":"post","link":"https:\/\/blog.abratel.com.br\/?p=929","title":{"rendered":"Upgrading MYSQL 5.0 or 5.1 to5.5 or 5.6 on Freebsd"},"content":{"rendered":"<p>Hi there!<\/p>\n<p>I just completed our upgrade of mysql so I thought I\u2019d let people know how to do it the correct way as I can see alot of people missing some vital steps to have everything running smoothly afterwards. I managed to do the upgrade with 15 seconds of downtime (when you install 5.5 it will shutdown mysql-server so while installing mysql will be offline).<\/p>\n<p>1. The first thing you have to do is check what ports depends on your current version of mysql-client, this can be done by issuing<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n(root@)~#  portupgrade -frn mysql-client\r\n<\/pre>\n<p>Se n\u00e3o souber ou caso n\u00e3o retorne a vers\u00e3o do mysql verificar com o comando:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\n(root@)~# mysql --version\r\nmysql  Ver 14.14 Distrib 5.6.24, for FreeBSD9.1 (amd64) using  EditLine wrapper\r\n\r\nObs: Esse print foi feito ap\u00f3s minha atualiza\u00e7\u00e3o. Provavelmente ver\u00e1s uma vers\u00e3o inferior a esta.\r\n<\/pre>\n<p>if you\u2019re using portmaster you obvisously have to change the flags to whatever the portmaster equivalent is, but as im a portupgrade kind of guy I wont get into that. What this command does is that it tries to force rebuild all ports that depends on mysql-client, but as we also used the \u201dn\u201d flag, it wont start doing anything (only a test). So you should now have a huuuuge list of ports that requires the mysql-client port to work correctly, save this list to a safe location because you will need it later (you can remove mysql-client and mysql-server from this list as your going to reinstall those anyway)<\/p>\n<p>2. Now before you start doing anything stupid, after issuing the below stated commands, do NOT restart apache\/php-fpm afterwards until you have rebuilt apache\/php because you will then get downtime due to that because those softwares will stop working until rebuilt. If you\u2019re using postfix for mail, it will stop working at the moment you deinstall mysql51-server, so if you\u2019re using postfix for your mailaccounts, you want to rebuild that port the first thing you do in step 3 and then restart postfix.<\/p>\n<p>Dependendo da vers\u00e3o visualizada, entrar no ports para realizar a remo\u00e7\u00e3o:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\n#Realizar um stop na servidor mysql:\r\n(root@)~# \/usr\/local\/etc\/rc.d\/mysql-server stop\r\n\r\n(root@)~# cd \/usr\/ports\/databases\/mysql51-client  # caso seja 5.0 -- &gt; cd \/usr\/ports\/databases\/mysql51-client\r\n(root@)~# make deinstall\r\n(root@)~# cd \/usr\/ports\/databases\/mysql51-server # caso seja 5.0 -- &gt; cd \/usr\/ports\/databases\/mysql50-server\r\n(root@)~# make deinstall\r\n\r\n<\/pre>\n<p>Now install mysql 5.5 server (will install mysql 5.5 client automatically)<\/p>\n<p>Realizar a instala\u00e7\u00e3o do Mysql mais atual:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n(root@)~#  cd \/usr\/ports\/databases\/mysql56-client\r\n(root@)~#  make install clean\r\n\r\n(root@)~# cd \/usr\/ports\/databases\/mysql56-server\r\n(root@)~# make install clean\r\n\r\n# Restart do servidor\r\n\r\n(root@)~#  shutdown -r now\r\n\r\n<\/pre>\n<p>No meu caso o mysql n\u00e3o subiu corretamente ap\u00f3s restart.<br \/>\nPrecisei editar o arquivo \/etc\/rc.conf<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n(root@)~#  vim \/etc\/rc.conf\r\nmysql_enable=&quot;YES&quot;\r\nmysql_args=&quot;--skip-grant-tables&quot;\r\n\r\n\r\n(root@)~#  \/usr\/local\/etc\/rc.d\/mysql-server restart\r\n\r\n# Verificar se subiu com:\r\n\r\n(root@)~# \/usr\/local\/etc\/rc.d\/mysql-server status\r\nmysql is running as pid 2049.\r\n\r\n#Conectei no mysql com qualquer senha uma vez que no rc.conf fizemos um skip grant tables:\r\n\r\n(root@orion)~# mysql -uroot -p123\r\nWarning: Using a password on the command line interface can be insecure.\r\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\r\nYour MySQL connection id is 602\r\nServer version: 5.6.24 Source distribution\r\n\r\nCopyright (c) 2000, 2015, Oracle and\/or its affiliates. All rights reserved.\r\n\r\nOracle is a registered trademark of Oracle Corporation and\/or its\r\naffiliates. Other names may be trademarks of their respective\r\nowners.\r\n\r\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\r\n\r\nmysql&gt;\r\n\r\n<\/pre>\n<p>Now that you\u2019ve got the new shit installed, fire it up and also run mysql_upgrade afterwards<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# Realizei o update\r\n\r\n(root@)~#  mysql_upgrade -u root -p\r\n\r\nComentei no rc.conf a linha abaixo:\r\n(root@)~#  vim \/etc\/rc.conf\r\nmysql_enable=&quot;YES&quot;\r\n#mysql_args=&quot;--skip-grant-tables&quot;\r\n\r\nRealizei um novo restart \r\n(root@)~#  \/usr\/local\/etc\/rc.d\/mysql-server restart\r\n\r\nO modulo alarmou que j\u00e1 estava sendo usado. \r\nRebootar o servidor:\r\n \r\n(root@)~#  shutdown -r now\r\n\r\n\r\n<\/pre>\n<p>After mysql_upgrade is done I usually restart mysql again (just in case)<\/p>\n<p>3. You now have mysql 5.5 installed and running, however, all your software are still using the 5.1 client, so at this point, DO NOT RESTART ANY SOFTWARE. As most software keeps a copy of it\u2019s libraries in memory so everything should be working just fine until restart.<\/p>\n<p>If you\u2019re running postfix, the first thing you want to do is this<\/p>\n<p>portupgrade -fO postfix<br \/>\n# If your using mysql as userdatabase<br \/>\nportupgrade -fO p5-DBD-mysql<br \/>\n# If your using spamassassin<br \/>\nportupgrade -fO p5-Mail-SpamAssassin<br \/>\nThere is probably more p5- ports that you have in your list, rebuild all those and then restart postfix and you should be good to go.<\/p>\n<p>Now, take the list of ports you saved in step 1 and rebuild every single one of them. You probably have alot of php ports in it if you\u2019re using php, heres an easy way of getting that stuff rebuilt without problems<\/p>\n<p>portupgrade -fO php5*<br \/>\n# If your also using pecl modules and eaccelerator<br \/>\n# issue the below command<br \/>\nportupgrade -fO pecl* eaccelerator<br \/>\nIf you\u2019re using apache you probably have apache22, mod_perl and apr1 in the list<\/p>\n<p>portupgrade -fO www\/apache22 www\/mod_perl2 devel\/apr1<br \/>\nThe most basic webstuff is now done and it\u2019s safe to restart apache, however, you will have to rebuild all ports you have in your list for them to work correctly. So before restarting a software, make sure you have rebuilt that port and those ports that it depends on. When you think your done, meaning you have rebuilt all ports in your list, you can run pkgdb -F to remove all the dependencies to the old mysql-client. After that you can run portversion just to check that there is no dependency warning, if there is no warning, well done!<\/p>\n<p>Thats all from me this time, hope this helped someone out.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi there! I just completed our upgrade of mysql so I thought I\u2019d let people know how to do it the correct way as I can see alot of people missing some vital steps to have everything running smoothly afterwards. I managed to do the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/929"}],"collection":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=929"}],"version-history":[{"count":4,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/929\/revisions"}],"predecessor-version":[{"id":932,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/929\/revisions\/932"}],"wp:attachment":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}