2012년 9월 14일 금요일

Mac에서-macport를-이용하여-mysql-설치하는-방법

http://ydux.tistory.com/entry/Mac%EC%97%90%EC%84%9C-macport%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%98%EC%97%AC-mysql-%EC%84%A4%EC%B9%98%ED%95%98%EB%8A%94-%EB%B0%A9%EB%B2%95




이 글은 나의 경험과 구글링으로 찾은 웹페이지 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!


이상.

macport subversion downgrade

macport에서 subversion을 downgrade할 일이 생겼다(1,7.x -> 1.6.x).
현재로서는 간단하게 하는 방법은 없는 듯하고 아래처럼 수동으로 해야한다. 
$ cd /tmp
$ svn co http://svn.macports.org/repository/macports/trunk/dports/devel/subversion
$ cd subversion
$ svn log
......
------------------------------------------------------------------------
r85581 | dluke@macports.org | 2011-10-15 03:56:06 +0900 (Sat, 15 Oct 2011) | 2 lines

subversion: version bump, subversion and bindings ports to 1.7.0

------------------------------------------------------------------------
r80777 | blair@macports.org | 2011-07-17 14:55:53 +0900 (Sun, 17 Jul 2011) | 5 lines

subversion, subversion-javahlbindings, subversion-rubybindings,
subversion-python26bindings, subversion-python27bindings,
subversion-python24bindings, subversion-perlbindings,
subversion-python25bindings: Depend upon serf0 instead of serf.
......
$ cd ..
$ svn co -r 80777 http://svn.macports.org/repository/macports/trunk/dports/devel/subversion subversion80777
$ cd subversion80777
$ sudo port install
......
--->  Attempting to fetch subversion-1.6.17_1......
......
$ port installed subversion
The following ports are currently installed:
  subversion @1.6.17_1 (active)
  subversion @1.7.3_1
 
refs:
http://reinout.vanrees.org/weblog/2008/09/19/macports-downgrading-subversion.html
https://trac.macports.org/wiki/howto/InstallingOlderPort 

happy hackin'