# 解压tar -zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.9-linux-glibc2.5-x86_64 /usr/local/mysql-5.7.9
# 安装依赖
yum install -y libaio
# 创建mysql数据目录mkdir -p /data/mysql/data
# 修改权限chown -R mysql:mysql /data/mysql
# 软连接,为了方便ln -s /usr/local/mysql-5.7.9 /mysql
cd /mysql
vi /etc/profile
export MYSQL_HOME=/mysql
export PATH=$MYSQL_HOME/bin:$PATHsource /etc/profile
#记得把root的临时密码记录下来,等会登录要用 -<tJ%?fa38*l
mysqld --user=mysql --basedir=/mysql --datadir=/data/mysql/data/ --initialize
# 修改mysql的文件权限chown -R root .# mysql启动脚本cp /mysql/support-files/mysql.server /etc/init.d/mysqld
cp /mysql/bin/my_print_defaults /usr/bin/
basedir=/mysql
datadir=/data/mysql/data
port=3306
mysql -u root -p
set password ='root@1234@';
flush privileges;
create database my_database;
use my_database;# 设置ip段访问# localhost,127.0.0.1和本机的ip是不一样的,需要分别设置,否则很可能被拒绝访问# 192.168.91.% 192.168.91.0针对192.168.91.0~255网段允许访问# 可以针对select,update等操作进行权限操作,细粒度可到某一列,防止删库跑路
grant all on my_database to 'mysql'@'localhost' identified by 'mysql@1234@local' with grant option;
grant all on my_database to 'mysql'@'127.0.0.1' identified by 'mysql@1234@127' with grant option;
grant all on my_database to 'mysql'@'192.168.91.%' identified by 'mysql@1234@ip' with grant option;# 每次修改权限记得刷新
flush privileges;