文章详情

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

请输入下面的图形验证码

提交验证

短信预约提醒成功

CentOS 6.7下yum方式怎么安装MySQL 5.6

2024-04-02 19:55

关注

本篇文章给大家分享的是有关CentOS 6.7下yum方式怎么安装MySQL 5.6,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

1、下载yum源

 我的测试环境如下:

[root@test ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)

所以下载了centos6系统yum源:

wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm

3、修改yum源配置

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

安装mysql5.6操作

1)、将其他版本enabled=1更改为enabled=0

2)、将5.6版本enabled=0更改为enabled=1

# Enable to use MySQL 5.6

[mysql56-community]

name=MySQL 5.6 Community Server

baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

4、开始现在安装包并安装

[root@test ~]# yum install mysql-community-server

已加载插件:fastestmirror, security

设置安装进程

Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com

 * epel: mirrors.yun-idc.com

 * extras: mirrors.aliyun.com

 * updates: mirrors.aliyun.com

解决依赖关系

--> 执行事务检查

---> Package mysql-community-server.x86_64 0:5.6.47-2.el6 will be 安装

--> 处理依赖关系 mysql-community-common(x86-64) = 5.6.47-2.el6,它被软件包 mysql-community-server-5.6.47-2.el6.x86_64 需要

--> 处理依赖关系 mysql-community-client(x86-64) >= 5.6.10,它被软件包 mysql-community-server-5.6.47-2.el6.x86_64 需要

--> 执行事务检查

---> Package mysql-community-client.x86_64 0:5.6.47-2.el6 will be 安装

--> 处理依赖关系 mysql-community-libs(x86-64) >= 5.6.10,它被软件包 mysql-community-client-5.6.47-2.el6.x86_64 需要

---> Package mysql-community-common.x86_64 0:5.6.47-2.el6 will be 安装

--> 执行事务检查

---> Package mysql-community-libs.x86_64 0:5.6.47-2.el6 will be 安装

--> 完成依赖关系计算

依赖关系解决

================================================================================================================================================================

 软件包                                        架构                          版本                                仓库                                      大小

================================================================================================================================================================

正在安装:

 mysql-community-server                        x86_64                        5.6.47-2.el6                        mysql56-community                         77 M

为依赖而安装:

 mysql-community-client                        x86_64                        5.6.47-2.el6                        mysql56-community                         34 M

 mysql-community-common                        x86_64                        5.6.47-2.el6                        mysql56-community                        341 k

 mysql-community-libs                          x86_64                        5.6.47-2.el6                        mysql56-community                        3.6 M

事务概要

================================================================================================================================================================

Install       4 Package(s)

总文件大小:114 M

总下载量:77 M

Installed size: 478 M

确定吗?[y/N]:y

下载软件包:

mysql-community-server-5.6.47-2.el6.x86_64.rpm                                                                                           |  77 MB     43:30    

warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Importing GPG key 0x5072E1F5:

 Userid : MySQL Release Engineering <mysql-build@oss.oracle.com>

 Package: mysql57-community-release-el6-7.noarch (installed)

 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

确定吗?[y/N]:y

运行 rpm_check_debug

执行事务测试

事务测试成功

执行事务

Warning: RPMDB altered outside of yum.

  正在安装   : mysql-community-common-5.6.47-2.el6.x86_64                                                                                                   1/4

  正在安装   : mysql-community-libs-5.6.47-2.el6.x86_64                                                                                                     2/4

  正在安装   : mysql-community-client-5.6.47-2.el6.x86_64                                                                                                   3/4

  正在安装   : mysql-community-server-5.6.47-2.el6.x86_64                                                                                                   4/4

  Verifying  : mysql-community-libs-5.6.47-2.el6.x86_64                                                                                                     1/4

  Verifying  : mysql-community-common-5.6.47-2.el6.x86_64                                                                                                   2/4

  Verifying  : mysql-community-client-5.6.47-2.el6.x86_64                                                                                                   3/4

  Verifying  : mysql-community-server-5.6.47-2.el6.x86_64                                                                                                   4/4

已安装:

  mysql-community-server.x86_64 0:5.6.47-2.el6                                                                                                                 

作为依赖被安装:

  mysql-community-client.x86_64 0:5.6.47-2.el6         mysql-community-common.x86_64 0:5.6.47-2.el6         mysql-community-libs.x86_64 0:5.6.47-2.el6       

完毕!

5、启动mysql服务

[root@test ~]# service mysqld start

初始化 MySQL 数据库: 2020-03-30 23:47:20 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2020-03-30 23:47:20 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

  /usr/bin/mysqladmin -u root password 'new-password'

  /usr/bin/mysqladmin -u root -h test password 'new-password'

Alternatively you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test

Note: new default config file not created.

Please make sure your config file is current

WARNING: Default config file /etc/my.cnf exists on the system

This file will be read by default by the MySQL server

If you do not want to use this, either remove it, or use the

--defaults-file argument to mysqld_safe when starting the server

                                                           [确定]

正在启动 mysqld:                                          [确定]

6、查看状态和版本

[root@test ~]#  chkconfig --list | grep mysqld

mysqld          0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭

[root@test ~]# mysqladmin --version

mysqladmin  Ver 8.42 Distrib 5.6.47, for Linux on x86_64

[root@test ~]#  mysqladmin -u root password "mysql123"

Warning: Using a password on the command line interface can be insecure.

[root@test ~]# mysql -u root -p

Enter password:

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

Your MySQL connection id is 3

Server version: 5.6.47 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, 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.

7、设置root用户密码

[root@test ~]#  mysqladmin -u root password "mysql123"

Warning: Using a password on the command line interface can be insecure.

8、查看数据库和创建数据库

[root@test mysql]# 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.6.47 MySQL Community Server (GPL)

mysql> show databases;

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

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

3 rows in set (0.00 sec)

mysql> CREATE DATABASE testtb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

Query OK, 1 row affected (0.00 sec)

mysql> show databases;

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

| testtb             |

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

4 rows in set (0.00 sec)

9、查看数据库目录

[root@test ~]# ls /var/lib/mysql -al

总用量 110616

drwxr-xr-x   5 mysql mysql     4096 3月  31 00:19 .

drwxr-xr-x. 30 root  root      4096 3月  30 20:57 ..

-rw-rw----   1 mysql mysql       56 3月  30 23:47 auto.cnf

-rw-rw----   1 mysql mysql 12582912 3月  30 23:47 ibdata1

-rw-rw----   1 mysql mysql 50331648 3月  30 23:47 ib_logfile0

-rw-rw----   1 mysql mysql 50331648 3月  30 23:47 ib_logfile1

drwx------   2 mysql mysql     4096 3月  30 23:47 mysql

srwxrwxrwx   1 mysql mysql        0 3月  30 23:47 mysql.sock

drwx------   2 mysql mysql     4096 3月  30 23:47 performance_schema

drwx------   2 mysql mysql     4096 3月  31 00:19 testtb

以上就是CentOS 6.7下yum方式怎么安装MySQL 5.6,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。

阅读原文内容投诉

免责声明:

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

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

软考中级精品资料免费领

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

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

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

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

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

    难度     221人已做
    查看

相关文章

发现更多好内容

猜你喜欢

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