# Update MySQL 5.0



## puzor (Jul 1, 2009)

Hello,

i will update my mysql server 5.0 to 5.1.

My current ports are:

mysql-client-5.0.83 Multithreaded SQL database (client)
mysql-server-5.0.83 Multithreaded SQL database (server)

i update my ports and run the command "portupgrade -r -R mysql-\*"

i got these messages:


```
[Gathering depends for databases/mysql50-client . done]
[Gathering depends for lang/php5-extensions .............................................................................................................................................................. done]
[Gathering depends for devel/apr ................ done]
[Gathering depends for databases/mysql50-server .. done]
[Gathering depends for www/lighttpd .............. done]
[Exclude up-to-date packages .............................................................. done]
```

What's the matter? portupgrade don't want update mysql?


Greet


----------



## vivek (Jul 1, 2009)

Try it as follows

```
portupgrade -o databases/mysql51-server/ mysql50-server
```

or


```
pkg_info | grep mysql
portmaster -o /usr/ports/databases/mysql51-server/ mysql-server-5.0.83 to upgrade mysql51-server
```

You may need to adjust version numbers as per your local setup.


----------



## dennylin93 (Jul 1, 2009)

`$ portupgrade -r -R mysql-\*` only checks the specified port for new versions. Sometimes there are different ports for major releases, such as 5.0 and 5.1; therefore, they aren't compared against each other.

The -o option for ports-mgmt/portmaster and ports-mgmt/portupgrade tells the system to replace the latter port with the former one. See `$ man portmaster` and `$ man portupgrade` for more details.

Make backups and read Upgrading MySQL before upgrading, in case something goes wrong.


----------



## puzor (Jul 1, 2009)

hey guys,

many thanks!

i will try it out! is portmaster better as portupgrade? i used only portupgrade for updating my freebsd system.

i maked a update script like this:


```
pkgdb -uF
portsnap fetch update
portupgrade -aP
portsclean -C
```

what do you think about it?

@dennylin93: thank you for the backup link from mysql. i read it before i start my update!


----------



## DutchDaemon (Jul 1, 2009)

Your portupgrade command (-aP) suggests you're using a mixture of packages and ports. That's something portmaster doesn't handle, unless you use a separate package upgrading procedure. On the other hand, using portupgrade -aP will probably give you a 100% ports system sooner or later, because packages can trail ports by months, so portupgrade will build a port as soon as an up-to-date package is not available (which is pretty standard if you run portupgrade regularly, e.g. daily or weekly). The big advantage of portmaster over portupgrade is that it doesn't need helper applications like ruby and bdb. It's a self-contained application that uses the ports tree and nothing else.


----------



## puzor (Jul 2, 2009)

Yeah! I installed mysql 5.1 with portmaster!

ok, i will use portupgrade for the next updates. but i think upgrades are easy with postmaster. 

before i'm running my update script. i used the command "portaudit -Fda" to checking if installed ports are listed in a 
database of published security vulnerabilities. After installation it will update this security database automatically and include its reports in the output of the daily security run.

at last days i get these message:


```
auditfile.tbz                                 100% of   53 kB   50 kBps
portaudit: Database too old.
Old database restored.
portaudit: Download failed.
```

whats wrong?


----------



## DutchDaemon (Jul 2, 2009)

The auditfile seems to be ok again today.


```
portaudit -Fda
auditfile.tbz                                 100% of   53 kB   67 kBps
New database installed.
Database created: Thu Jul  2 12:20:02 CEST 2009
```


----------



## neildarlow (Jul 12, 2009)

puzor said:
			
		

> Hello,
> 
> i will update my mysql server 5.0 to 5.1.
> 
> ...



You need to be very careful about performing this update. The procedure I followed was:
	
	



```
1. Shutdown mysql and mysql-dependent services first
2. Use mysqldump to backup database mysql tables db, columns_priv, tables_priv and user (you should not need this)
3. Use mysqldump to backup your other databases
4. Use portupgrade -o to upgrade mysql-client, mysql-server, mysql-scripts and any mysql-dependent ports
5. Re-create /usr/local/etc/my.cnf from appropriate my-{small,medium,large,huge}.conf in /usr/local/share/mysql (settings have changed)
6. Start mysql as normal
7. Execute mysql_upgrade as mysql root user
8. If mysql_upgrade indicates some tables need REPAIR or dump/restore, execute mysql and source your other databases backup to recreate the broken tables
9. Restart mysql as normal
10. Start your mysql-dependent services
11. Delete old mysql client libraries from /usr/local/lib/compat/pkg/
```

This might seem long-winded but it's the only way to ensure that you have access to data and user information from the previous version of mysql and that changes to configuration variables are managed for the new version.

The mysql database backup (privilege information) shouldn't be required but it's wise to have it there in case that aspect of the mysql_upgrade fails and manual recovery of users/passwords/privileges would be difficult and error-prone.


----------



## puzor (Jul 14, 2009)

hey! 

thank you for your update workflow. i try it!


----------

