1、依赖安装
[root@localhost ~]# yum -y install numactl perl autoconf libaio
2、检查MySQL及相关RPM包,是否安装,如果有安装,则移除(rpm –e 名称)
## centos7主要检查maridb
[root@localhost ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@localhost ~]# yum -y remove mariadb*
## centos6检查情况
[root@bigdata-05 ~]# rpm -qa | grep -i mysql
mysql-libs-5.1.71-1.el6.x86_64
[root@bigdata-05 ~]# yum -y remove mysql-libs*
3、下载Linux对应的RPM包,如:CentOS6.4_64对应的RPM包,如下:
[root@bigdata-05 ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
4、安装
[root@bigdata-05 ~]# rpm -ivh mysql-community-common-5.7.32-1.el7.x86_64.rpm
[root@bigdata-05 ~]# rpm -ivh mysql-community-libs-5.7.32-1.el7.x86_64.rpm
[root@bigdata-05 ~]# rpm -ivh mysql-community-server-5.7.32-1.el7.x86_64.rpm
[root@bigdata-05 ~]# rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm
5、启动服务
[root@localhost ~]# systemctl start mysqld.service
6、找到登录密码
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
2020-11-11T12:34:21.064104Z 1 [Note] A temporary password is generated for root@localhost: T,RJgf,6k.cf
7、登录
[root@localhost ~]# mysql -uroot -pT,RJgf,6k.cf
8、修改密码
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
mysql> set password for root@localhost=password('root');
9、授权
mysql> grant all privileges on *.* to root@'%' identified by 'root';
mysql> flush privileges;
mysql> show grants;
配置文件
[mysqld]
port=3306
basedir=/usr/local/mysql
datadir=/mysql/data
socket=/tmp/mysql.sock
character_set_server=utf8
collation-server=utf8_general_ci
symbolic-links=0
log-error=/var/log/mysql/mysqld.log
pid-file=/var/run/mysql/mysqld.pid
[mysql]
default-character-set=utf8
[client]
default-character-set=utf8
网友评论