安装目录:
/usr/local/mysql 数据库软件安装目录
/home/mysql/mysql3306/data 设置数据库存放目录
[root@192 ~]# mkdir -p /usr/local/mysql
[root@192 ~]# mkdir -p /home/mysql/mysql3306/data
1.MySQL数据库软件包下载
官方下载地址: https://downloads.mysql.com/archives/community/ , 首先下载指定版本的rpm包,直接下载rpm所有需要的集合包,如图
2. 删除mariadb
[root@192 ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.44-2.el7.centos.x86_64
[root@192 ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
[root@192 ~]# rpm -qa|grep mariadb
[root@192 ~]#
3. 将数据库传到/usr/local/mysql目录
[root@192 ~]# cd /usr/local/mysql/
[root@192 mysql]# rz
[root@192 mysql]# ls
mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
[root@192 mysql]#tar -xvf mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
# 解压后会有很多rpm包,只需要其中四个,依次安装: common -> libs -> client -> server
rpm -ivh mysql-community-common-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.32-1.el7.x86_64.rpm
4. 启动mysql
[root@192 ~]# systemctl enable mysqld
[root@192 ~]# systemctl start mysqld
[root@192 ~]# systemctl enable mysqld.service #设置成开机启动
[root@192 ~]# systemctl is-enabled mysqld.service #查看开机启动是否成功
enabled
5. 开放防火墙
[root@192 ~]# firewall-cmd --add-port=3306/tcp --permanent
success
[root@192 ~]# firewall-cmd --reload
success
6. 登陆mysql,并修改root密码,开启远程访问
[root@192 ~]# grep password /var/log/mysqld.log #查看默认初始密码
2021-03-23T01:11:47.457592Z 1 [Note] A temporary password is generated for root@localhost: AZ=jP(esD37N
[root@192 ~]# mysql -u root -p # 利用初始密码登陆mysql
Enter password:
mysql> alter user 'root'@'localhost' identified by '12345678'; #修改密码
mysql>create database confluence default character set utf8 collate utf8_bin;
或者:alter database confluence default collate utf8_bin;
mysql> grant all on confluence.* to confluencer@"%" identified by "12345678"; confluence 数据库名称,confluencer 数据库用户,12345678数据库密码,所有用户可以登陆访问。
mysql> grant all on confluence.* to confluencer@"localhost" identified by "12345678"; confluence 数据库名称,confluencer 数据库用户,12345678数据库密码,本地用户可以登陆访问。
mysql> SET GLOBAL tx_isolation='READ-COMMITTED'; #设置默认隔离级别
mysql> grant all privileges on *.* to 'root'@'%' identified by '12345678'; #开启远程登陆
mysql> flush privileges;