MySQL源码编译安装

创建MySQL所需目录


mkdir /usr/local/mysql
mkdir /usr/local/mysql/etc
mkdir /usr/local/mysql/database


创建MySQL使用的用户和组


useradd mysql


检查编译环境,在检查完成后可通过“echo $?”命令检查是否有错误,当输入结果为0是表示没有错误


cd mysql
./configure --prefix-/usr/local/mysql --sysconfdir=/usr/local/mysql/etc \
--localstatedir=/usr/local/mysql/database --with-character=utf8


编译、安装MySQL


make & make install


安装mysql、test 和information_schema数据库


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


建立MySQL配置文件


cd /usr/local/mysql/
cp /usr/local/mysql/share/mysql/my-huge.cnf /etc/my.cnf
cp /usr/local/mysql/share/mysql.server /etc/rc.d/init.d/mysqld
chown -R mysql:mysql /usr/local/mysql/database/
chown -R mysql:mysql /usr/local/mysql/lib/
./bin/mysql_safe --user=mysql &


增加MySQL服务、启动服务并设置为下次启动自动加载


chkconfig --add mysqld
service mysqld restart
chkconfig mysqld onn


将MySQL相关命令复制到/sbin目录


cp /usr/local/mysql/bin/* /sbin


使用mysqladmin创建MySQL管理员及密码


mysqladmin -u root password abc123


你可能感兴趣的:(MySQL源码编译安装)