FreeBSD下安装MySQL
时间:2010-09-02 来源:kennychang05
本次通过ports方式来MySQL,首先安装以及更新Ports树。
#portsnap fetch extract #portsnap fetch update |
1、安装compat6x库
#cd /usr/ports/misc/compat6x #make install clean |
2、安装MySQL所需组件
#cd /usr/ports/devel/libtool22/ #make install clean #cd /usr/ports/converters/libiconv #make install clean |
3、安装MySQL服务与客户端程序
#cd /usr/ports/databases/mysql51-server #make install clean |
★.完成后使用pkg_info命令检查MySQL是否安装成功。
#pkg_info |grep mysql |
4.MySQL配置
#cd /usr/local/bin #./mysql_install_db --user=mysql #cp /usr/local/share/mysql/my-huge.cnf /etc/my.cnf #echo mysql_enable=\"YES\" >>/etc/rc.conf |
5.启动MySQL
第一次启动MySQL使用命令:
/usr/local/bin/mysqld_safe &
以后就可以使用下面命令来启动、关闭、重启MySQL:
/usr/local/etc/rc.d/mysql-server (start|stop|restart)
6.设置MySQL密码
#mysqladmin -uroot -p password 123456 |
下面附上安装脚本:
#!/bin/sh portsnap fetch extract cd /usr/ports/misc/compat6x && make install clean cd /usr/ports/devel/libtool22 && make install clean cd /usr/ports/converters/libiconv && make install clean cd /usr/port/databases/mysql51-server && make install clean cd /usr/local/bin && ./mysql_install_db --user=mysql cp /usr/local/share/mysql/my-huge.cnf /etc/my.cnf echo mysql_enable=\"YES\" >>/etc/rc.conf /usr/local/bin/mysqld_safe & |