此种方式安装非常简单
cd /usr/local
下载安装包
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
解压
tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
[[email protected] local]# pwd
/usr/local
[[email protected] local]# mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
cd mysql
mkdir -p /data/mysql/data
创建mysql 用户
useradd mysql -s /sbin/nologin -M(没有家目录)
chown -R mysql.mysql /data/mysql
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
提示初始密码:
2017-03-29T15:09:12.116410Z 1 [Note] A temporary password is generated for [email protected]: ew/Wx(<Z>43l
拷贝启动脚本文件
cp support-files/mysql.server /etc/init.d/mysqld
设置开机启动
chkconfig mysqld on
chkconfig --list|grep mysqld
chmod 755 /etc/init.d/mysqld
配置环境变量
echo ‘PATH=/usr/local/mysql/bin/:$PATH‘ >> /etc/profile
. /etc/profile
进入MySQL :
mysql -uroot -p ew/Wx(<Z>43l
修改密码
alter user ‘root‘@‘localhost‘ identified by ‘123456‘;
flush privileges;
grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘;
FLUSH PRIVILEGES;