Mysql安装与配置

Published on 2015 - 05 - 05

1.安装

1.1安装依赖包

 install gcc gcc-c++ make automake cmake conf autoconf ncurses-devel libtool libtool-devel libxml2-devel libtool libtool-ltdl-devel autoconf automake bison zlib zlib-devel

1.2下载并解压

tar -zxvf mysql-5.6.11.tar.gz -C /us    r/src

1.3创建用户与组

groupadd mysql
useradd -r -s /sbin/nologin -g mysql mysql

1.4编译并安装

cd /usr/src/mysql-5.6.11
cmake . -DENABLE_DOWNLOADS=1
make && make install
chown -R mysql.mysql /usr/local/mysql

2.初始化数据库

2.1初始化

cd /usr/local/mysql/scripts
mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
cp /usr/local/mysql/my.cnf /etc/my.cnf

2.2启动Mysql并设置开机启动

/usr/local/mysql/bin/mysqld_safe --user=mysql &
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
PATH=$PATH:/usr/local/mysql/bin
echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile

3.初始化数据库设置

cd /bin/
mysql_secure_installation