只针对mysql5.6,其他版本mysql_install_db步骤可能有所不同.

yum安装依赖包

1
2
3
4
5
$ yum install gcc-c++
$ yum install cmake
$ yum install make
$ yum install bison.x86_64
$ yum install ncurses-devel.x86_64

解压并编译mysql

1
2
3
4
$ tar -xzvf mysql.**.tar.gz
$ cd /usr/local/mysql
$ cmake .
$ make && make install

常见用户组及用户

1
2
$ groupadd mysql
$ useradd -r -g mysql mysql

安装MySQL

1
2
$ chmod 777 scripts/mysql_install_db
$ scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data