Linux在线安装Mysql教程(超详细超简单 全程复制语句即可)
Linux在线安装Mysql
安装mysql
1.下载yum Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
- 1
如果不行就用下面这个命令
wget http://repo.mysql.com/mysql-community-release-el7-10.noarch.rpm
- 1
2.安装yum Repository
yum -y install mysql57-community-release-el7-10.noarch.rpm
- 1
3.安装mysql5.7的服务
yum -y install mysql-community-server
- 1
如果出现安装失败,原因是:Mysql的GPG升级了,需要重新获取,使用以下命令即可
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
- 1
之后再将安装服务的命令重新执行一遍
yum -y install mysql-community-server
- 1
4.设置开机自启动
systemctl enable mysqld.service
- 1
5.启动mysql
systemctl start mysqld.service
- 1
6.查看状态
systemctl status mysqld.service
- 1
7.获取临时密码
grep "password" /var/log/mysqld.log
- 1
8.登录mysql
mysql -uroot -p
- 1
9.关闭密码复杂验证
set global validate_password_policy=0;
set global validate_password_length=1;
- 1
- 2
10.设置密码
alter user user() identified by "123123";
- 1
11.修改权限
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123123' WITH GRANT OPTION;
- 1
- 2
刷新权限
flush privileges;
- 1
查看权限
select host,user,authentication_string from user;
- 1
12.卸载yum Repository
防止每次自动更新,卸载yum Repository先退出mysql再输入下面的命令
yum -y remove mysql57-community-release-el7-10.noarch
- 1
卸载mysql
如果安装的过程中出现了错误,需要卸载mysql ,卸载方法如下:
1.删除依赖包
rpm -qa | grep -i mysql
- 1
yum remove mysql-community mysql-community-server mysql-community-libs mysql-community-common
- 1
2.清理文件
find / -name mysql
- 1
rm -rf 文件名
- 1