如何yum安装mysql5.7_Centos7 yum安装mysql5.7

Centos 7中将MySQL数据库软件从默认的程序列表中移除,用mariadb代替。

也就是说不能再跟之前6一样,直接使用yum进行安装,需要使用官网提供的软件源进行安装,此次安装版本为5.7

1.安装官网提供的yum源

# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

# rpm -ivh mysql57-community-release-el7-11.noarch.rpm

2.安装MySQL

# yum -y install mysql-server

3.修改Mysql配置文件

[root@host-192-168-8-37 ~]# vim /etc/my.cnf

[mysqld]

character-set-server=utf8

4.启动MySQL

q启动MySQL

[root@master ~]# systemctl start mysqld

q设置MySQL为开机启动

[root@master ~]# systemctl enable mysqld

5.修改密码&进入MySQL数据库

Mysql5.7版本及之后不再使用空密码,在安装时会生成临时密码并保存在日志文件中

[root@host-192-168-8-37 ~]# grep 'password' /var/log/mysqld.log

2017-10-16T02:12:56.016829Z 1 [Note] A temporary password is generated for root@localhost: #zua)gQ?e5Gi

这里将用户的密码修改为:Mysql_password123

[root@host-192-168-8-37 yum.repos.d]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.7.19

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> alter user 'root'@'localhost' identified by 'Mysql_password123';

Query OK, 0 rows affected (0.00 sec)

mysql>

6.配置MySQL

q创建数据库(数据库名称:cache_cloud;编码:UTF-8)

mysql> create database cache_cloud default charset utf8;

Query OK, 1 row affected (0.00 sec)

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| cache_cloud        |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

5 rows in set (0.01 sec)

mysql>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值