CentOS 安裝 MySQL
下載 MySQL 安裝包
MySQL :: Download MySQL Community Server

安裝 MySQL
解壓安裝包
rpm -ivh mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar

安裝
安裝 mysql-community-common-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-8.0.27-1.el7.x86_64.rpm

安裝 mysql-community-client-plugins-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.27-1.el7.x86_64.rpm

安裝 mysql-community-libs-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.27-1.el7.x86_64.rpm

安裝 mysql-community-client-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.27-1.el7.x86_64.rpm

安裝 mysql-community-server-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.27-1.el7.x86_64.rpm

數(shù)據(jù)庫配置
初始化 MySQL
# 初始化數(shù)據(jù)庫及相關(guān)配置
mysqld --initialize;
chown mysql:mysql /var/lib/mysql -R;
systemctl start mysqld.service;
systemctl enable mysqld;
# 查看數(shù)據(jù)庫密碼
cat /var/log/mysqld.log |grep password
修改密碼
使用上一步查詢到的密碼登錄數(shù)據(jù)庫,修改密碼
alter uer 'root'@'localhost' identified with mysql_native_password by '你的密碼';
允許遠(yuǎn)程訪問
create user 'root'@'%' identified with mysql_native_password by '你的密碼';
grant all privileges on '*' to 'root'@'%' with grant option;
flush privileges;
修改加密規(guī)則
alter user 'root'@'localhost' identified by '你的密碼' PASSWORD EXPIRE NEVER;
flush privileges;
開放 3306 端口
關(guān)閉 firewall
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl mask firewalld.service
安裝 iptables
yum install -y iptables-services
配置 iptables
# 啟動(dòng)
systemctl enable iptables
systemctl start iptables
開放 3306 端口
vim /etc/sysconfig/iptables
- iptables 添加 3306 端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
- 重啟 iptables
service iptables restart
使用 DBeaver 連接 MySQL


posted on 2022-12-29 18:12 今天的阿洋依舊很菜 閱讀(7) 評(píng)論(0) 收藏 舉報(bào)
浙公網(wǎng)安備 33010602011771號(hào)