Centos7 yum安装mysql5.7
admin
2023-05-01 15:03:27
0

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>


相关内容

热门资讯

特朗普要求中国对美经贸团队访问... 澎湃新闻记者 杨文钦 朱郑勇5月13日,外交部发言人郭嘉昆主持例行记者会。法新社记者提问,美国总统特...
美媒又想起这茬:2年前在地中海... 【文/观察者网 阮佳琪】2024年12月23日,载有16名船员的俄罗斯“大熊星座”号货船在西班牙近海...
App过度索取授权或被境外间谍... 微信公众号“国家安全部”5月13日发文: 手机里各种各样的应用程序(APP)五花八门,在方便我们生...
广合科技获得发明专利授权:“一... 证券之星消息,根据天眼查APP数据显示广合科技(001389)新获得一项发明专利授权,专利名为“一种...
华尔街科技老将:大科技公司分化... 5月11日,互联网泡沫时期的知名芯片分析师、Niles Investment Management创...
香港80后“地产女王”烧炭身亡... 据《香港01》报道,5月12日,香港九龙传统豪宅地段加多利山畔的豪宅项目Kadoorie Hill发...
谷歌发布安卓 AI 系统,这就... 和去年一样,在正式的 Google I/O 开发者大会之前,谷歌为 Android 单独开了一次小型...
300斤医生走红 曾一年猛涨1...   300斤医生走红 曾一年猛涨100斤  【300斤医生走红 曾一年猛涨100斤】5月11日,上海...
新乡市主要负责同志职务调整 日前,中共河南省委决定:魏建平同志任中共新乡市委书记,李卫东同志不再担任中共新乡市委书记、常委、委员...
九阳电饭锅H01故障 H01是因为上盖异常高温,有可能是机板不良造成的;同时也可能是故障前没有清洗上盖或溢出米浆等情况造成...