| 191 | |
| 192 | |
| 193 | ==== Optional database upgrade ==== #mysql_upgrade |
| 194 | |
| 195 | If the database exists from a previous installation, you may need to upgrade. |
| 196 | |
| 197 | {{{ |
| 198 | man mysql_upgrade |
| 199 | sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper restart |
| 200 | sudo /opt/local/lib/mysql5/bin/mysql_upgrade -u root -p |
| 201 | sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper restart |
| 202 | }}} |
| 203 | |
| 204 | |
| 205 | ==== Optional security configuration ==== #mysql_security |
| 206 | |
| 207 | Place the following into {{{mysql_security.sql}}} and replace the {{{'MyNewPass'}}} with your root password. Note that the SQL will remove all access for root from any location other than 'localhost'. You might like to keep this SQL file - all the lines beginning with '--' are doc-comments about how to use it. |
| 208 | |
| 209 | {{{ |
| 210 | -- HOW TO USE THIS FILE (with a MacPorts installation): |
| 211 | -- $ sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop |
| 212 | -- $ sudo mysqld_safe5 --init-file=mysql_security.sql & |
| 213 | -- The init will terminate if there are any errors in the init file. |
| 214 | -- Wait a bit to be sure the server is running. |
| 215 | -- If it's running, then shutdown the server (root password required): |
| 216 | -- $ /opt/local/bin/mysqladmin5 -u root -p shutdown |
| 217 | -- Check that everything worked. There may be an ERROR if the test database |
| 218 | -- doesn't exist. Otherwise there should be no errors in the file reported by |
| 219 | -- 'mysqld_safe Logging to ..." during the mysql_safe5 startup from above: |
| 220 | -- $ sudo tail -n 20 /opt/local/var/db/mysql5/*.err |
| 221 | |
| 222 | UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; |
| 223 | DELETE FROM mysql.user WHERE User='root' AND Host!='localhost'; |
| 224 | DELETE FROM mysql.user WHERE User=''; |
| 225 | FLUSH PRIVILEGES; |
| 226 | DROP DATABASE test; |
| 227 | DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'; |
| 228 | }}} |
| 229 | |
| 230 | See also http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html#resetting-permissions-unix |
| 231 | |
| 232 | |