centos7下rpm安装mysql
# 下载安装包
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
1
2
3
4
5
2
3
4
5
# 卸载mariadb
rpm -qa | grep mariadb
rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps
1
2
3
2
3
# 按顺序安装
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
# 问题解决
如果你的系统版本太高,可能会报如下错误
Error: Problem: conflicting requests
- nothing provides libtinfo.so.5()(64bit) needed by mysql-community-client-5.7.35-1.el7.x86_64 from @commandline
- nothing provides libncurses.so.5()(64bit) needed by mysql-community-client-5.7.35-1.el7.x86_64 from @commandline (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
解决方法:
使用 ncurses-compat-libs
来安装兼容性库,这通常是最安全和最有效的方案。
dnf install epel-release
dnf install ncurses-compat-libs
# 配置数据目录
vi /etc/my.cnf
#mysql用户
user=mysql
#数据目录
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
启动之前请确保mysql目录是否是mysql用户权限
# 启动服务并修改root密码
#启动服务
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;
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
上次更新: 2024/10/18, 18:39:32