FreeBSD 7.0 安装MySQL 5.0.51a

1,去FreeBSD.org下载相应的安装包(packages):

ftp://ftp.freebsd.org/pub/FreeBSD/ports/packages/
devel/libtool-1.5.24.tbz
ftp://ftp.freebsd.org/pub/FreeBSD/ports/packages/
databases/mysql-client-5.0.51a.tbz
ftp://ftp.freebsd.org/pub/FreeBSD/ports/packages/
databases/mysql-server-5.0.51a.tbz

2,装上面下载的三个文件拷贝到同一个目录下,执行下面的命令进行安装:

cd /var/ftp/incoming
pkg_add mysql-server-5.0.51a.tbz

3,提示安装完成,接着执行:

/usr/local/bin/mysql_install_db –user=mysql

4,启动Mysql:

/usr/local/bin/mysqld_safe –user=mysql &

5,修改mysql的密码:

/usr/local/bin/mysqladmin -u root password ‘123456789’

或者

/usr/local/bin/mysqladmin -u root -h demo.localdomain
password ‘123456789’

初次安装时候root密码为空. 如果用户root有旧密码,此时会提示输入旧密码.

6,在另一台电脑上测试是否启动成功:

telnet 192.168.232.129 3306

出现错误提示:
FHost ‘192.168.232.1′ is not allowed to connect to this MySQL server
解决办法:

/usr/local/bin/mysql -u root -p
输入密码后进入mysql管理控制台:
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED
BY ‘123456789’ WITH GRANT OPTION;

原理是:允许所有用root用户并且输入root密码的用户登入该mysql Server,
如果将’%’换成’10.1.1.1′那么只有10.1.1.1的主机可以登陆.

7,自动启动mysql:

ee /usr/local/etc/rc.d/mysql_start.sh
/usr/local/bin/mysqld_safe –user=mysql &

按 ctrl + [ 保存文件
执行:

chmod +x /usr/local/etc/rc.d/mysql_start.sh

完成mysql安装,并自启动.

Leave a Reply