Centos7使用yum安装Mysql

in 干货分享 with 0 comment

下载yum源

wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

或者去官网查看下载:https://dev.mysql.com/downloads/repo/yum/

安装yum源

rpm -ivh mysql80-community-release-el7-3.noarch.rpm

正常执行完上面命令后/etc/yum.repos.d/目录下会出现mysql-community.repomysql-community-source.repo两个repo文件

选择Mysql版本

repo配置文件.png

vi /etc/yum.repos.d/mysql-community.repo

修改需要安装mysql版本的enable参数为1,其它修改为0

安装Mysql

yum -y install mysql-community-server

启动Mysql

systemctl start mysqld

配置说明

mysql安装后会生成一个默认密码:cat /var/log/mysqld.log | grep password
随机密码.png
但是等你在命令行链接数据库后会发现什么都做不了,因为首次安装必须修改Mysql密码
提示需要修改密码.png

mysql> alter user 'root'@'localhost' identified by 'Linux6.cn';
Query OK, 0 rows affected (0.01 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.26    |
+-----------+
1 row in set (0.00 sec)

到这里基本就OK了,欢迎小伙伴随时补充问题

Responses