Centos7.6安装部署MYSQL8.0.25-generic

1.安装之前检查系统有没有mariadb客户端,如果有建议删除

检查

[root@localhost mysql]# rpm -qa |grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64

删除
[root@localhost mysql]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave

2.修改环境变量,增加PATH=$PATH:/usr/local/mysql/bin

[root@localhost ~]# vi .bash_profile 
# .bash_profile

# Get the aliases and functions
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
# .bash_profile

# Get the aliases and functions
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
PATH=$PATH:/usr/local/mysql/bin
".bash_profile" 12L, 207C written

source 生效当前环境变量
[root@localhost ~]# source .bash_profile

3.创建mysql用户、组

[root@mysql~]#groupadd mysql

[root@mysql~]#useradd -r -g mysql -s /bin/false mysql

4.创建mysql数据文件目录权限

[root@localhost /]# mkdir -p /mysql/data
[root@localhost /]# mkdir -p /mysql/binlog
[root@localhost /]# mkdir -p /mysql/log
[root@localhost /]# chown -R mysql:mysql /mysql
[root@localhost /]# chmod -R 755 /mysql
[root@localhost mysql]# ll /mysql/
total 4
drwxr-xr-x. 2 mysql mysql   77 Sep  4 16:46 binlog
drwxr-xr-x. 6 mysql mysql 4096 Sep  4 16:46 data
drwxr-xr-x. 2 mysql mysql   23 Sep  4 16:39 log

5.解压安装包

将mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz解压到/usr/local下面

[root@localhost home]# tar -xvf mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz -C /usr/local/

查看

[root@localhost local]# ll
drwxr-xr-x. 9 root root 129 Sep  4 16:04 mysql-8.0.25-linux-glibc2.12-x86_64

创建mysql软链接文件
[root@localhost local]# ln -s mysql-8.0.25-linux-glibc2.12-x86_64 mysql

查看

[root@localhost local]# ll
lrwxrwxrwx. 1 root root  35 Sep  4 16:09 mysql -> mysql-8.0.25-linux-glibc2.12-x86_64

mysql-file文件赋权限

[root@localhost mysql]# chown mysql:mysql support-files/
[root@localhost mysql]# chmod 750 support-files/
[root@localhost mysql]# ll
drwxr-x---.  2 mysql mysql     77 Apr 24  2021 support-files
 

6.初始化mysql server

初始化

[root@mysql mysql]#cd /usr/local/mysql 
[root@mysql mysql]#bin/mysqld --initialize --user=mysql 
配置ssl
[root@mysql mysql]#bin/mysql_ssl_rsa_setup


7.使用mysqld_safe启动mysql

[root@localhost mysql]# bin/mysqld_safe --user=mysql &
[1] 15084
[root@localhost mysql]# 2023-09-04T08:46:46.023173Z mysqld_safe Logging to '/mysql/log/error.log'.
2023-09-04T08:46:46.050112Z mysqld_safe Starting mysqld daemon with databases from /mysql/data

查看3306端口,有3306端口证明mysql已经启动

[root@localhost mysql]# ss -ln |grep 3306               
tcp    LISTEN     0      128      :::3306                 :::*                  
tcp    LISTEN     0      70       :::33060                :::*                

 

8.拷贝mysql.server启动文件到/etc/init.d/

[root@localhost mysql]cp support-files/mysql.server /etc/init.d/mysql.server

9.登录mysql

[root@localhost mysql]# mysql -uroot -h127.0.0.1 -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.25

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

密码可以在/mysql/log/error.log查看

cat /mysql/log/error.log

2023-09-04T08:44:41.465093Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-09-04T08:44:43.352202Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-09-04T08:44:44.720219Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: zPn3TwsnWA+n

修改初始化root密码
mysql密码的维度是用户名+主机,修改密码是需要根据用户名和主机的维度来一起修改
 
mysql> alter user 'root'@'localhost' identified by 'mysql123';
Query OK, 0 rows affected (0.01 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值