CentOS7安装MySQL
MySQL官网下载所需版本:
https://dev.mysql.com/downloads/repo/yum/
或者用wget命令下载:1
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
注意:
- 1.1.1、wget没安装的话需要先安装wget:sudo yum install -y wget
- 1.1.2、最好做一下和校验:
1
md5sum mysql57-community-release-el7-11.noarch.rpm
安装MySQL软件包的源:
1 | sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpm |
开始安装MySQL
1 | yum install mysql-community-server |
或者这条命令:1
sudo yum install mysql-server
启动MySQL服务:
1 | sudo systemctl start mysqld |
查看MySQL运行状态:
1 | sudo systemctl status mysqld |
如果看到一下内容说明安装并启动成功。1
2
3
4
5
6
7
8*
其他内容
*
Active: active (running)
*
其他内容
*
Started MySQL Server.
这个命令也行,不过最后会自动转到另一个命令1
service mysqld restart
实际执行效果:1
2[liudecai@a ~]$ service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
到此MySQL算是安装成功。
安装后可以用一下命令查看mysql的临时密码:1
sudo grep 'temporary password' /var/log/mysqld.log
配置MySQL:
1 | sudo mysql_secure_installation |
安装wget
1 | sudo yum install -y wget |