centos7下rpm安装mysql

2023-07-01 14:53:14 浏览数 (2)

# 下载安装包

代码语言:javascript复制
wget https://mirrors.cloud.tencent.com/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-client-5.7.35-1.el7.x86_64.rpm
wget https://mirrors.cloud.tencent.com/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-common-5.7.35-1.el7.x86_64.rpm
wget https://mirrors.cloud.tencent.com/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-devel-5.7.35-1.el7.x86_64.rpm
wget https://mirrors.cloud.tencent.com/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-libs-5.7.35-1.el7.x86_64.rpm
wget https://mirrors.cloud.tencent.com/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-server-5.7.35-1.el7.x86_64.rpm

# 卸载mariadb

代码语言:javascript复制
rpm -qa | grep mariadb

rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps

# 按顺序安装

yum install mysql-community-common-5.7.35-1.el7.x86_64.rpm -y

yum install mysql-community-libs-5.7.35-1.el7.x86_64.rpm -y

yum install mysql-community-devel-5.7.35-1.el7.x86_64.rpm -y

yum install mysql-community-client-5.7.35-1.el7.x86_64.rpm -y

yum install mysql-community-server-5.7.35-1.el7.x86_64.rpm -y

# 配置数据目录

代码语言:javascript复制
vi /etc/my.cnf
#数据目录
datadir=/data/database/mysql
#开启binlog
server-id=1
log_bin=/data/database/mysql/binlog/mysql-bin
#不区分大小写
lower_case_table_names=1
#设置字符集
character-set-server=utf8mb4
# 最大连接数.
max_connections=2048
# 打开的文件描述符限制.
open_files_limit=65535
group_concat_max_len = 102400

# 启动服务并修改root密码

代码语言:javascript复制
#启动服务
systemctl start mysqld
#查看密码
grep 'temporary password' /var/log/mysqld.log 
2023-06-21T08:40:31.470093Z 1 [Note] A temporary password is generated for root@localhost: VlVSj#4C1HyD

#登录
mysql -uroot -p
#修改密码
alter user 'root'@'localhost' identified by 'fasG344_32dsf';
#修改root账号具有远程连接权限
 grant all on *.* to root@'%' identified by 'fasG344_32dsf' with grant option;

0 人点赞