이 글은 나의 경험과 구글링으로 찾은 웹페이지 http://mdzyuba.blogspot.com/2007/11/mysql-macport-install-on-mac-os-x-tiger.html 을 부분적으로 번역 한 것임을 밝힌다.
먼저 macport를 설치한다. 구글에서 macport 등으로 검색하면 찾을 수 있을 것이다.
macport가 설치되면 다음 명령을 통해 mysql5를 설치 한다.
$ sudo port install mysql5
mysql5의 설치가 끝났으면 이제, 초기 database를 설치 해야 한다.
$ sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql
아웃풋은 다음과 같이 나와야 한다.
Installing MySQL system tables... 071118 0:06:29 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive OK Filling help tables... 071118 0:06:29 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password' /opt/local/lib/mysql5/bin/mysqladmin -u root -h my-computer.local password 'new-password' See the manual for more instructions. You can start the MySQL daemon with: cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com
이 상태에서 mysql 데몬을 띄우면 다음과 같이 에러가 난다.
$ sudo /opt/local/lib/mysql5/bin/mysqld_safe mkdir: /opt/local/var/run: No such file or directory chown: /opt/local/var/run/mysql5: No such file or directory chmod: /opt/local/var/run/mysql5: No such file or directory Starting mysqld daemon with databases from /opt/local/var/db/mysql5 STOPPING server from pid file /opt/local/var/db/mysql5/mykola-dzyubas-computer-2.local.pid 071118 00:27:12 mysqld ended
따라서 다음 명령어 들을 입력하여 같이 디렉토리를 수동으로 생성 해 준다.
sudo mkdir /opt/local/var/run sudo chmod g+w /opt/local/var/run sudo mkdir /opt/local/var/run/mysql5 sudo chown mysql /opt/local/var/run/mysql5
그러면 이제 mysql 데몬이 잘 실행 될 것이다.
$ sudo /opt/local/lib/mysql5/bin/mysqld_safe & Starting mysqld daemon with databases from /opt/local/var/db/mysql5
mysql 서버가 잘 떠 있는지 체크하는 방법은 다음과 같다.
$ mysqladmin5 -u root -p ping Enter password: mysqld is alive
다음과 같이 mysql 명령으로 mysql5 클라이언트를 띄울 수 있도록 만들면 편하다.
$ cd /opt/local/bin $ ln -s mysql5 mysql
보안을 강화하기 위하여 다음과 같은 명령어를 내리면 좋다. 특히 mysql로 조그마한 서비스라도 제공한다면 보안 강화 명령을 주는 것이 좋다.
$ cd /opt/local/bin $ ./mysql_secure_installation5 mykola-dzyubas-computer-2:/opt/local/bin mykola$ ./mysql_secure_installation5
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] n ... skipping. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL!
이상.