mysql下载地址
https://downloads.mysql.com/archives/community/
安装环境信息
mysql版本 :5.7.19版本
安装包:mysql-5.7.19-1.el7.x86_64.rpm-bundle.tar
linux版本(cat /proc/version) :Linux version 3.10.0-1062.18.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Tue Mar 17 23:49:17 UTC 2020
开始安装
查找以前是否安装有mysql,使用下面命令,安装则删除
查询命令
rpm -qa|grep mariadb
rpm -qa|grep -i mysql
删除命令
rpm -e --nodeps xxxx
例如:rpm -e --nodeps mysql-community-common-5.7.19-1.el7.x86_64.rpm
解压压缩包并安装
tar -xvf mysql-5.7.19-1.el7.x86_64.rpm-bundle.tar 解压
rpm -ivh mysql-community-common-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.19-1.el7.x86_64.rpm
安装rpm包过程中报依赖包错误则需要安装依赖包再继续安装
yum install libaio
安装完毕实例目录创建
mkdir -p /data/mysqldata3307
cd /data/mysqldata3307
mkdir binlog innodb_log innodb_ts log mydata relaylog sock tmpdir
chown -R mysql:mysql /data/mysqldata3307
配置文件my.cnf(可参考my.cnf配置文件)https://www.cnblogs.com/whiteY/p/13287951.html
/etc/my.cnf
实例初始化及启动
systemctl start mysqld@3307
如果报以下错误请参考https://www.cnblogs.com/whiteY/p/13286214.html
Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld3306.service" and "journalctl -xe" for details.
连接mysql并修改密码
第一次登录只能用socket登录
启动时,I7会在error.log中打印初始化该实例时的密码
[root@cdh02 log]# grep ‘temporary password‘ ./error.log
2020-07-12T03:07:15.306108Z 1 [Note] A temporary password is generated for root@localhost: J_qF6Oi5xr?i
mysql -uroot -S /data1/mysqldata3307/sock/mysql.sock -p"J_qF6Oi5xr?i"
修改密码强度为最弱,默认最强
set global validate_password_policy=0;
修改密码长度最少的为8位
set global validate_password_length=8;
修改密码
set password=‘abc123456‘;
赋予权限
GRANT ALL PRIVILEGES ON . TO ‘root‘@‘127.0.0.1‘ identified by ‘abc123456‘ WITH GRANT OPTION ;
刷新改动
flush privileges;
新密码连接
mysql -uroot -pabc123456 -P3307 -h127.0.0.1