1.下载yum
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
→ yum -y install mysql57-community-release-el7-10.noarch.rpm
→ yum -y install mysql-community-server(可能会出现以下报错)

注意:在安装mysql-community-server可能会出现以下报错:

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql57-community-release-el7-10.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


Public key for mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm is not installed


 Failing package is: mysql-community-libs-compat-5.7.37-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

这个报错是指mysql密钥过期了,需要更新一下密钥,更新完密钥之后,重新安装mysql-community-server即可。

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
→ yum -y install mysql-community-server
2.启动mysql
→ systemctl start  mysqld.service
→ systemctl status mysqld.service
→ systemctl enable mysqld.service
3.查看mysql临时密钥
grep "password" /var/log/mysqld.log
4.登录mysql修改密码和创建远程登录用户
→  mysql -uroot -p
→  ALTER USER 'root'@'localhost' IDENTIFIED BY 'P@ssword123';
→  systemctl restart mysqld
→  GRANT ALL PRIVILEGES ON *.* TO 'bigdata'@'%' IDENTIFIED BY 'P@ssword123' WITH GRANT OPTION;
→  GRANT select,Insert,UPDATE,delete ON *.* TO 'test1'@'%' IDENTIFIED BY 'P@ssword123' WITH GRANT OPTION;
→  GRANT select,Insert,UPDATE,delete ON *.* TO 'test2'@'%' IDENTIFIED BY 'P@ssword123' WITH GRANT OPTION;
5.修改字符集,在字符集中添加以下内容
vim /etc/my.cnf
#修改字符集
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
# binlog 配置
log-bin=mysql-bin
server-id=1
binlog_format=ROW
expire_logs_days = 14
6.重启mysql服务
→  systemctl restart mysqld
→  SHOW VARIABLES LIKE 'character_set_%';
7.mysql安装后的相关文件在如下路径
配置文件:/etc/my.cnf
日志文件: /var/log/mysqld.log
服务启动脚本: /usr/lib/systemd/system/mysqld.service
socket文件: /var/run/mysqld/mysqld.pid
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐