1、#cd /usr/ports/databases/mysql51-server
2、#make install clean 接下来是等待系统下载mysql包,编译和安装
3、# /usr/local/bin/mysql_install_db 安装初始化数据库
4、#chown -R mysql /var/db/mysql
#chown -R mysql:mysql /var/db/mysql
#chmod 777 /var/db/mysql
接下来就可以起动mysql了,/usr/local/bin/mysqld_safe &
5、如果要让msyql支持远程登录,则必须添加远程登录用户信息
5、如果要让msyql支持远程登录,则必须添加远程登录用户信息
登录mysql:/usr/local/bin/mysql
添加用户:格式:grant 权限 on 数据库名.表名 用户@登录主机 identified by "用户密码";
如:grant select,update,insert,delete on *.* to root@192.168.0.2 identified by "root";
更新用户为任意主机登录:update user set host = '%' where user = 'root' and password='root';
将用户信息添加到db表:insert into db
values('%','%','root','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
update db set host = '%' where user = 'root' ;
如:grant select,update,insert,delete on *.* to root@192.168.0.2 identified by "root";
更新用户为任意主机登录:update user set host = '%' where user = 'root' and password='root';
将用户信息添加到db表:insert into db
values('%','%','root','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
update db set host = '%' where user = 'root' ;