文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

麒麟服务器系统安装mysql-5.7

2023-09-15 13:11

关注

1. 基础环境

############## NeoKylin Linux Version#################Release:NeoKylin Linux Advanced Server release V7Update6 (Chromium)Kernel:3.10.0-957.el7.x86_64Build:NeoKylin Linux Advanced Serverrelease V7Update6/(Chromium)-x86_64b4.lic/20190820#################################################
[root@localhost ~]# rpm -qa | grep mysqlmysql-community-server-5.7.40-1.el7.x86_64mysql-community-client-5.7.40-1.el7.x86_64mysql80-community-release-el7-7.noarchmysql-community-common-5.7.40-1.el7.x86_64mysql-community-libs-5.7.40-1.el7.x86_64

2. 移除系统自带MariaDB

[root@localhost ~]# yum remove mariadb*

3. 安装MySQL 5.7

因为中标麒麟 V7.6 系统源中并没有MySQL,所以我们需要手动添加MySQL的仓库源。好在MySQL官方为我们提供了MySQL的仓库源,所以我们直接使用就好了。

wget https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm
rpm -ivh mysql80-community-release-el7-7.noarch.rpm
[root@localhost ~]# yum repolist all | grep mysqlmysql-cluster-7.5-community/x86_64           MySQL Cluster 7.5 Comm 禁用mysql-cluster-7.5-community-source           MySQL Cluster 7.5 Comm 禁用mysql-cluster-7.6-community/x86_64           MySQL Cluster 7.6 Comm 禁用mysql-cluster-7.6-community-source           MySQL Cluster 7.6 Comm 禁用mysql-cluster-8.0-community/x86_64           MySQL Cluster 8.0 Comm 禁用mysql-cluster-8.0-community-debuginfo/x86_64 MySQL Cluster 8.0 Comm 禁用mysql-cluster-8.0-community-source           MySQL Cluster 8.0 Comm 禁用mysql-connectors-community/x86_64            MySQL Connectors Commu 启用:    206mysql-connectors-community-debuginfo/x86_64  MySQL Connectors Commu 禁用mysql-connectors-community-source            MySQL Connectors Commu 禁用mysql-tools-community/x86_64                 MySQL Tools Community  启用:     94mysql-tools-community-debuginfo/x86_64       MySQL Tools Community  禁用mysql-tools-community-source                 MySQL Tools Community  禁用mysql-tools-preview/x86_64                   MySQL Tools Preview    禁用mysql-tools-preview-source                   MySQL Tools Preview -  禁用mysql57-community/x86_64                     MySQL 5.7 Community Se 禁用mysql57-community-source                     MySQL 5.7 Community Se 禁用mysql80-community/x86_64                     MySQL 8.0 Community Se 启用:    367mysql80-community-debuginfo/x86_64           MySQL 8.0 Community Se 禁用mysql80-community-source                     MySQL 8.0 Community Se 禁用

这里可以看到默认启用的是mysql 8.0的仓库源。因为我们要安装mysql 5.7,所以我们要禁用mysql 8.0的仓库源,启用mysql 5.7的仓库源。

[root@localhost ~]# yum-config-manager --disable mysql80-community[root@localhost ~]# yum-config-manager --enable mysql57-community[root@localhost ~]#[root@localhost ~]#[root@localhost ~]#[root@localhost ~]# yum repolist all | grep mysqlmysql-cluster-7.5-community/x86_64           MySQL Cluster 7.5 Comm 禁用mysql-cluster-7.5-community-source           MySQL Cluster 7.5 Comm 禁用mysql-cluster-7.6-community/x86_64           MySQL Cluster 7.6 Comm 禁用mysql-cluster-7.6-community-source           MySQL Cluster 7.6 Comm 禁用mysql-cluster-8.0-community/x86_64           MySQL Cluster 8.0 Comm 禁用mysql-cluster-8.0-community-debuginfo/x86_64 MySQL Cluster 8.0 Comm 禁用mysql-cluster-8.0-community-source           MySQL Cluster 8.0 Comm 禁用mysql-connectors-community/x86_64            MySQL Connectors Commu 启用:    206mysql-connectors-community-debuginfo/x86_64  MySQL Connectors Commu 禁用mysql-connectors-community-source            MySQL Connectors Commu 禁用mysql-tools-community/x86_64                 MySQL Tools Community  启用:     94mysql-tools-community-debuginfo/x86_64       MySQL Tools Community  禁用mysql-tools-community-source                 MySQL Tools Community  禁用mysql-tools-preview/x86_64                   MySQL Tools Preview    禁用mysql-tools-preview-source                   MySQL Tools Preview -  禁用mysql57-community/x86_64                     MySQL 5.7 Community Se 启用:    624mysql57-community-source                     MySQL 5.7 Community Se 禁用mysql80-community/x86_64                     MySQL 8.0 Community Se 禁用mysql80-community-debuginfo/x86_64           MySQL 8.0 Community Se 禁用mysql80-community-source                     MySQL 8.0 Community Se 禁用

再次查看,我们发现mysql 5.7的仓库源已经启用了。这里我们也可以选择手动编辑 /etc/yum.repos.d/mysql-community.repo ,来启用 mysql 5.7的仓库源。方法就是将文件中 mysql80-community enabled选项设置为0,将mysql57-community enabled选项设置为1。

[root@localhost ~]# yum install mysql-community-server#安装完成之后,查看安装情况[root@localhost ~]# rpm -qa | grep mysqlmysql-community-server-5.7.40-1.el7.x86_64mysql-community-client-5.7.40-1.el7.x86_64mysql80-community-release-el7-7.noarchmysql-community-common-5.7.40-1.el7.x86_64mysql-community-libs-5.7.40-1.el7.x86_64

4. 初始化MySQL

[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl enable mysqld
[root@localhost ~]# systemctl status mysqld● mysqld.service - MySQL Server   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)   Active: active (running) since 四 2022-11-10 14:21:09 CST; 838ms ago     Docs: man:mysqld(8)           http://dev.mysql.com/doc/refman/en/using-systemd.html  Process: 16055 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)  Process: 15960 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 16058 (mysqld)    Tasks: 27   CGroup: /system.slice/mysqld.service           └─16058 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid11月 10 14:21:04 localhost.localdomain systemd[1]: Starting MySQL Server...11月 10 14:21:09 localhost.localdomain systemd[1]: Started MySQL Server.[root@localhost ~]#[root@localhost ~]#

mysql安装成功之后会为root账户生成一个临时随机密码,这个临时随机密码我们可以在/var/log/mysqld.log文件中找到。

[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log2022-11-10T06:21:06.369797Z 1 [Note] A temporary password is generated for root@localhost: 9eh*

知道临时随机密码后,我们就可以登录mysql,将root账户的密码设置成任何我们想要的密码了。

[root@localhost ~]# mysql -uroot -pEnter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.40Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> 

因为mysql的密码规则需要很复杂,这里我们想把密码设置得简单一些,所以我们需要修改一下mysql的密码规则。这一步大家可以根据现场情况自行决定是否修改。

mysql> set global validate_password_policy=0;mysql> set global validate_password_length=1;

接下来将root账户的密码设置成我们想要的。

ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword';

至此,mysql安装完毕,你可以根据自己的需求使用mysql数据库了。

5. 参考资料

A Quick Guide to Using the MySQL Yum Repository
centos7 安装 Mysql 5.7.28,详细完整教程

来源地址:https://blog.csdn.net/zhajianting/article/details/127790839

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯