OSX: Installing mysql on 10.6

1. Download mysql-5.0.92.tar.gz

2. Unpackage to /usr/local/mysql-5.0.92/

3. Create symlink mysql

cd /usr/local/
ln -s /usr/local/mysql-5.0.92/ mysql

4. Open Terminal and set temporary PATH

export PATH=$PATH:/usr/local/mysql/bin

5. Create 2 folders

mkdir tmp
mkdir var

6. Configure mysql
./configure --prefix=/usr/local/mysql \
--with-extra-charsets=all \
--enable-thread-safe-client \
--with-unix-socket-path=/usr/local/mysql/tmp/socket \
--with-mysqld-user=mysql \
--with-comment \
--with-debug

7. Install mysql

make
make install

8. If during the installation process you encounter the following error:
/usr/bin/install -c 'bench-count-distinct' '/usr/local/mysql/sql-bench/bench-count-distinct'
install: bench-count-distinct and /usr/local/mysql/sql-bench/bench-count-distinct are the same file
make[3]: *** [install-benchSCRIPTS] Error 64
make[2]: *** [install-am] Error 2
make[1]: *** [install-recursive] Error 1

You aren't alone, the problem is with the OS and directory name resolution. The fix is to simply ignore these errors.

option A. make -i install

option B. edit /usr/local/mysql/sql-bench/Makefile line 418

from:

$(...) "$$d$$p" "$(DESTDIR)$(benchdir)/$$f"; \

to:

$(...) "$$d$$p" "$(DESTDIR)$(benchdir)/$$f" 2>/dev/null | wc -l; \

9. installing the database

sudo /usr/local/mysql/bin/mysql_install_db --force

10. create mysql user

dscl . -create /Users/mysql
dscl . -create /Users/mysql UserShell /usr/bin/false
dscl . -create /Users/mysql NFSHomeDirectory /dev/null
dscl . -passwd /Users/mysql PASSWORD

11. giving permission to mysql to write files

sudo chown -R mysql /usr/local/mysql

12. running the database (sudo is needed unless you are running from mysql account/root)

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

13. creating a database root user

/usr/local/mysql/bin/mysqladmin -u root password rootpwd

14. stop running databases

/usr/local/mysql/bin/mysqladmin shutdown

15. as was the case with the tomcat server, here's a mini script that can simplify starting and shutting down the mysql server
#!/bin/bash
export PATH=$PATH:/usr/local/mysql/bin
if [ "$1" == "start" ]; then
sudo mysqld_safe -user=mysql &
elif [ "$1" == "stop" ]; then
sudo mysqladmin shutdown
elif [ "$1" == "info" ]; then
mysqladmin version
else
echo "Command: mysql [start|stop|info]"
fi

No comments: