查看mysql文件
rpm -qa | grep mysql
下載環(huán)境
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
執(zhí)行環(huán)境
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
安裝
yum install mysql-server
mysql -V
service mysqld start
service mysqld status
重啟
service mysqld restart
進入mysql
查看初始密碼
grep "password" /var/log/mysqld.log
mysql -uroot -p')pyaL.S+I6k.'
修改密碼
SET PASSWORD = PASSWORD('Admin123.0');
永不過期
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
創(chuàng)建外網(wǎng)訪問root賬戶 xxxxxx(password)
輸入你的密碼
grant all privileges on *.* to 'root'@'%' identified by 'xxxxxx(password)' with grant option;
更新
flush privileges;
查看數(shù)據(jù)庫
show databases;
使用數(shù)據(jù)庫
use mysql
看表
show tables;
查看遠程 IP
select user,host from user;
修改用戶的host
update user set host="%" where user="root";
退出
exit;
重啟
service mysqld restart
部署端口:
1 登錄控制臺->安全組->配置規(guī)則->添加安全組->設置數(shù)據(jù)庫默認的3306端口號携栋,訪問對象設置為 0.0.0.0/0
2 cmd設置防火墻
firewall-cmd --zone=public --list-ports
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
firewall-cmd 常用命令請見:firewall-cmd
卸載
- 快速刪除
yum remove mysql mysql-server mysql-libs mysql-server
- 查找殘留文件
rpm -qa | grep -i mysql
將查詢出來的文件刪除
yum remove mysql-community-common-5.7.20-1.el6.x86_64
刪除殘余目錄
whereis mysql
rm –rf /usr/lib64/mysql
- 刪除依賴
## 查找依賴
yum list installed | grep mysql
## 刪除找到的依賴
yum -y remove mysql-libs.x86_64
出現(xiàn)錯誤
解決:
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install -y mysql-community-server