1.下载和解压mysql数据库
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.9-linux-glibc2.5-x86_64.tar.gzs
tar -xvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz -C /usr/local/mysql-5.7.9
2.建立软链接
ln -s mysql-5.7.9 mysql
3.创建mysql用户和修改软件的权限
useradd -r -M -s /sbin/nologin mysql
chown -R mysql.mysql /usr/local/mysql-5.7.9
chown -R mysql.mysql /usr/local/mysql
chgrp -R mysql /usr/local/mysql-5.7.9
4.安装和初始化数据库
cd /usr/local/mysql-5.7.9/
bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.7.9/ --datadir=/usr/local/mysql-5.7.9/data/ --必须在mysql根目录安装mysql,否则出错
cp -a ./support-files/my-default.cnf /etc/my.cnf
cp -a ./support-files/mysql.server /etc/init.d/mysqld
#cd bin/
#./mysqld_safe --user=mysql &
[root@db2 scripts]# /etc/init.d/mysqld restart
Shutting down MySQL.. [ OK ]
Starting MySQL... [ OK ]
#开机启动
chkconfig --level 35 mysqld on
5.初始化密码
mysql5.7会生成一个初始化密码,而在之前的版本首次登陆不需要登录。
shell> cat /root/.mysql_secret
mysql -uroot -p
SET PASSWORD = PASSWORD('123456');
flush privileges