安装mysql5.7系列版本
1.官网下载mysql,目前5.7系列版本为mysql-5.7.22-linux-glibc2.12-x86_64.tar
2.放在/usr/logcal 下解压压缩包,并改名为mysql
cd /usr/local/
tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar
mv mysql-5.7.22-linux-glibc2.12-x86_64 mysql
3.创建用户组mysql,创建用户mysql并将其添加到用户组mysql中,并赋予读写权限
groupadd mysql
useradd -r -g mysql mysql
chown -R mysql mysql/
chgrp -R mysql mysql/
4.创建配置文件
vim /etc/my.cnf ===========================内容============================== [client] port = 3306 socket = /tmp/mysql.sock [mysqld] character_set_server=utf8 init_connect='SET NAMES utf8' basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/tmp/mysql.sock log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid #不区分大小写 lower_case_table_names = 1 sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION max_connections=5000 default-time_zone = '+8:00'
5.初始化数据库
yum install libaio #手动编辑一下日志文件,什么也不用写,直接保存退出 cd /var/log/ vim mysqld.log :wq chmod 777 mysqld.log chown mysql:mysql mysqld.log /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US
6.查看初始密码(最后那一串)
cat /var/log/mysqld.log
7.启动
/usr/local/mysql/support-files/mysql.server start
如果到这一步没出现问题,那基本没什么问题了!如果中途出现问题,查询mysql下收录的相关错误!
8.修改初始密码
set password=password('新密码'); flush privileges;