三九宝宝网宝宝百科宝宝知识

安装mysql的方法

01月06日 编辑 39baobao.com

#cd /usr/ports/databases/mysql5l1-server

#make WITH_CHARSET=gbk WITH_XCHARSET=all WITH_PROC_SCOPE_PTH=yes BUILD_OPTIMIZED=yes BUILD_STATIC=yes SKIP_DNS_CHECK=yes WITHOUT_INNODB=yes install clean

#rehash;rehash;rehash;

#cp /usr/local/share/mysql/my-large.cnf /etc/my.cnf

#设置随机启动:

vi /etc/rc.conf

mysql_enable="YES"

#初始化:

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

#更改数据库权限(若所有者不是mysql):

chown -R mysql /var/db/mysql/

#立即启动:

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

修改密码

#/usr/local/bin/mysqladmin -u root password 'newpasswd'

就好了,

#mysql -u root 进入看看,

#show databases;

#mysqladmin shutdown 关掉mysql,并退出;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

mysql的默认安装路径是:/var/db/mysql

如果要更改为/usr/local/mysql可按下面的步骤操作:

# /usr/local/etc/rc.d/mysql-server.sh stop

# cd /var/db

# mv mysql /usr/local/

# ln -s /usr/local/mysql mysql

# cd /usr/local

# chown -R mysql:mysql mysql

# /usr/local/etc/rc.d/mysql-server.sh start

推荐阅读
图文推荐