MYSQL 8.0安装(RPM)

安装过程:

0. mysql安装包下载

    链接:https://pan.baidu.com/s/1CGbehC7s7Bb93a_kCpz_Zw     提取码:nyde

1. 查看Linux中是否已安装mysql

ps -ef | grep mysql

2. 查看当前安装的mariadb包(安装新版mysql之前,我们需要将系统自带的mariadb-lib卸载)

rpm -qa | grep mariadb  查看当前安装的mariadb包
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64 强制卸载过程1的运行结果

3. 在mysql安装包路径下解压安装包

tar -xvf mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar 

4. 安装mysql的rpm软件包

rpm -ivh mysql-community-common-8.0.15-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.15-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.15-1.el7.x86_64.rpm  
rpm -ivh mysql-community-embedded-compat-8.0.15-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.15-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.15-1.el7.x86_64.rpm --force --nodeps

注:如果运行失败,可以在后面加上--force --nodeps进行强制安装

5. 创建 mysql 的数据文件目录以及所属组

mkdir /u01/mysql
mkdir /u01/mysql/logs
chown -R mysql:mysql /u01/mysql

6. 修改配置文件/etc/my.cnf

[mysqld]
server-id=61
port=38960
character-set-server=utf8mb4
default-time_zone='+8:00'
lower_case_table_names=1
max_connections=3000
max_connect_errors=100000
default_authentication_plugin=mysql_native_password
datadir=/u01/mysql/data
socket=/u01/mysql/mysql.sock
log-error=/u01/mysql/logs/mysqld.log
pid-file=/u01/mysql/mysqld.pid
long_query_time=1
slow_query_log = 1
slow_query_log_file=/u01/mysql/logs/slow.log
[client]
port=38960
default-character-set=utf8mb4
socket=/u01/mysql/mysql.sock
[mysql]
no-auto-rehash
default-character-set=utf8mb4

7. 关闭 selinux,确保 getenforce 的值为 Permissive

setenforce 0    关闭 selinux
getenforce      获取getenforce的值

注:输出结果需为:Permissive 否则可以选择手动修改,如下SELINUX=permissive

vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

8. 启动mysql

systemctl start mysqld

9. 查看root密码

    如果上一步没有问题,可在 /data/mysql/logs/mysqld.log 文件中查看root密码。

cat /u01/mysql/logs/mysqld.log    

10. 进入mysql命令行界面

mysql -uroot -p   运行后输入上一步查看的root密码

11. 修改root账号密码

alter user 'root'@'localhost' identified by 'KnjVPbv0kZ5IJ!*g';

12. 将mysql加入开机自动启动

vi /etc/rc.local
添加:service mysqld start

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
>