1、到mysql官网下载安装包

下载地址:https://dev.mysql.com/downloads/mysql/5.6.html#downloads

选择以下截图中的版本

2、下载后上传到linux中

3、安装

卸载系统自带的mariadb

[root@localhost soft]# rpm -qa | grep mariadb
mariadb-libs-5.5.-.el7.x86_64
[root@localhost soft]#
[root@localhost soft]#
[root@localhost soft]# rpm -e --nodeps mariadb-libs-5.5.-.el7.x86_64

删除/etc目录下的my.cnf

[root@localhost soft]# rm /etc/my.cnf
rm: 无法删除"/etc/my.cnf": 没有那个文件或目录
[root@localhost soft]#

有可能本身就不存在这个文件。

创建mysql用户组

[root@localhost soft]# groupadd mysql

创建一个用户名为mysql的用户并加入mysql用户组

[root@localhost soft]# useradd -g mysql mysql

解压安装包到/usr/local/目录下

tar -xvf mysql-5.6.-linux-glibc2.-x86_64.tar.gz -C /usr/local/

切换到/usr/local目录下,并查看

[root@localhost soft]# cd /usr/local/
[root@localhost local]# ls
bin etc games include java lib lib64 libexec mysql-5.6.-linux-glibc2.-x86_64 redis sbin share src
[root@localhost local]#
[root@localhost local]#

将解压好的文件夹重命名为mysql

[root@localhost local]# mv mysql-5.6.-linux-glibc2.-x86_64/ mysql
[root@localhost local]# ls
bin etc games include java lib lib64 libexec mysql redis sbin share src
[root@localhost local]#

copy一份/usr/local/mysql/support-files/下的my-default.cnf文件到/etc下

cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

配置/etc目录下的my.cnf文件

通过vi编辑器,编辑my.cnf的代码如下

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8 [mysqld]
skip-name-resolve
#设置3306端口
port =
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data
# 允许最大连接数
max_connections=
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_name=
max_allowed_packet=16M

进入安装mysql软件目录,并执行以下命令

[root@localhost mysql]# cd /usr/local/mysql/
[root@localhost mysql]# chown -R mysql:mysql ./
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
-bash: ./scripts/mysql_install_db: /usr/bin/perl: 坏的解释器: 没有那个文件或目录
[root@localhost mysql]#
[root@localhost mysql]#

如果报上面的错误,那么需要安装perl

yum install perl

安装完成后,再次执行./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
[root@localhost mysql]#
[root@localhost mysql]#

如果报上面的错误,那么需要安装autoconf

 yum install autoconf

安装完成后,再次执行上面的那个命令。

安装完成后,修改当前data目录的拥有者为mysql用户

[root@localhost mysql]# chown -R mysql:mysql data

到此数据库安装完毕!

4、配置

授予my.cnf权限

chmod 644 /etc/my.cnf

设置开机自启动服务控制脚本

复制启动脚本到资源目录

[root@localhost mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld

增加mysqld服务控制脚本执行权限

chmod +x /etc/rc.d/init.d/mysqld

将mysqld服务加入到系统服务

chkconfig --add mysqld

检查mysqld服务是否已经生效

chkconfig --list mysqld

结果类似如下

[root@localhost mysql]#  chkconfig --list mysqld

注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。 要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。 mysqld :关 :关 :开 :开 :开 :开 :关
[root@localhost mysql]#

表明mysqld服务已经生效,在2、3、4、5运行级别随系统启动而自动启动,以后可以使用service命令控制mysql的启动和停止

命令为:service mysqld start和service mysqld stop

启动mysqld

[root@localhost mysql]# service mysqld start
Warning: World-writable config file '/etc/my.cnf' is ignored
Starting MySQL.Warning: World-writable config file '/etc/my.cnf' is ignored
Warning: World-writable config file '/etc/my.cnf' is ignored
Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
. SUCCESS!
[root@localhost mysql]#

将mysql的bin目录加入PATH环境变量,编辑 ~/.bash_profile文件

在文件最后添加如下信息:

export PATH=$PATH:/usr/local/mysql/bin

保存并退出。

使修改的内容立即生效

source ~/.bash_profile

以root账户登录mysql,默认是没有密码的

[root@localhost mysql]# mysql -uroot -p
Warning: World-writable config file '/etc/my.cnf' is ignored
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.6. MySQL Community Server (GPL) Copyright (c) , , 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>

要求输入密码的时候,直接回车。

设置root账户的密码

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> update user set password=password('root') where user='root' and host='localhost';
Query OK, row affected (0.00 sec)
Rows matched: Changed: Warnings: mysql> flush privileges;
Query OK, rows affected (0.00 sec) mysql>

设置远程主机登录

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
Query OK, rows affected (0.00 sec) mysql>

开启3306端口

[root@localhost mysql]# systemctl start firewalld
[root@localhost mysql]# firewall-cmd --zone=public --add-port=/tcp --permanent
success
[root@localhost mysql]# firewall-cmd --reload
success

到此为止,在Centos 7上安装mysql5.6就完成了。

centos7 安装 mysql5.6(mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz)的更多相关文章

  1. CentOS7安装MySQL5.7及Tomcat8.5

    在CentOS7服务器上部署FR项目应用 一.安装CentOS-7_x86_64 1.CentOS7:带GUI的服务器(FTP服务器.JAVA平台.兼容性程序库.开发工具.安全性工具.系统管理工具): ...

  2. 搭建MHA环境【2】安装mysql-5.6 + mysql复制

    本例中mysql的安装方式选用了二进制包安装方案.mysql复制用半同步复制方案 [1]安装mysql-5.6.31 要在所有的数据节点上都安装上mysql,安装方式大致相同,所以我这里就不重复写多次 ...

  3. Centos7 安装 MySQL5.7

    Centos7 安装 MySQL5.7 一.环境介绍 1.安装包版本介绍 MySQL 有三种安装方式:RPM安装.二进制包安装.源码包安装.我们这篇文章以二进制方式安装MySQL 软件名称 版本 系统 ...

  4. linux centos7 安装mysql-5.7.17教程(图解)

    1系统约定安装文件下载目录:/data/softwareMysql目录安装位置:/usr/local/mysql数据库保存位置:/data/mysql日志保存位置:/data/log/mysql 2下 ...

  5. 002. Centos7安装mysql5.5.37

    下载cmake-2.8.12.2.tar.gz, 下载地址: https://pan.baidu.com/s/1qYtpX7m 下载mysql-5.5.37.tar.gz, 下载地址: http:// ...

  6. centos7安装mysql5.7.19及配置远程连接

    centos7安装mysql5.7.19及配置远程连接------https://blog.csdn.net/Lh19931122/article/details/77996213

  7. centos7 安装mysql5.7(二进制安装)

    一.卸载默认安装的mariadb [root@localhost ~]# yum remove mariadb* -y 二.添加mysql用户 [root@localhost ~]# useradd ...

  8. centos7 安装 mysql5.7.25

    一.检查是否安装了mysql和mariadb,若已经安装就需要卸载. [root@localhost ~]# rpm -qa|grep mariadb // 查询出来已安装的mariadb [root ...

  9. centos7安装mysql5.5.62

    mysql是我们最常用的开源的关系型数据库,mysql不同版本有时候安装的方式也不尽相同,下面梳理一下mysql5.5.62版本的安装 1.下载mysql5.5.62,URL:https://down ...

随机推荐

  1. 在论坛中出现的比较难的sql问题:5(row_number函数 分页、随机返回数据)

    原文:在论坛中出现的比较难的sql问题:5(row_number函数 分页.随机返回数据) 所以,觉得有必要记录下来,这样以后再次碰到这类问题,也能从中获取解答的思路. 1.在inner join后, ...

  2. SQL Server系统函数:类型转换函数

    原文:SQL Server系统函数:类型转换函数 1.基本的转化 SELECT CAST(2008 as varchar(4)) + ' year!' SELECT CONVERT(varchar(4 ...

  3. SQL logic error no such module: fts5 解决方案

    因项目原因,需要使用SQLite的全文索引,用到了最新的fts5模块 但在咱们.net framwork中却会提示“SQL logic error no such module: fts5”:找不到f ...

  4. Python考试_第三次

    - python 全栈11期月考题 一 基础知识:(70分) 1.文件操作有哪些模式?请简述各模式的作用(2分) 2.详细说明tuple.list.dict的用法,以及它们的特点(3分) 3.解释生成 ...

  5. S2-033、S2-037

    前言 S2-033漏洞和S2-032类似,也是由于开启了动态方法调用,action mapper中的执行的方法名可控,导致了ognl表达式注入. 正文 Rest插件中获取action mapper是用 ...

  6. Python使用selenium模拟点击,进入下一页(三)

    嗯,昨天呢,我们已经实现了自动输入百度然后搜索Cgrain,然后点击按钮,进入我的页面,在这里呢,有个问题 ActionChains(seleniumGoo).move_by_offset(-480, ...

  7. PAT Basic 1075 链表元素分类 (25 分)

    给定一个单链表,请编写程序将链表元素进行分类排列,使得所有负值元素都排在非负值元素的前面,而 [0, K] 区间内的元素都排在大于 K 的元素前面.但每一类内部元素的顺序是不能改变的.例如:给定链表为 ...

  8. 使用C#的Flags特性

    举个例子:我有如下的一个需求,当我想要取得用户信息的时候,会先从本地缓存中查找,找不到然后从分布式缓存中查找,最后找不到再从数据库中查询.但是有些场景我又不需要查询数据库. 所以我想建立如下这种模型. ...

  9. jade-mixin 代码的重用

    有时候页面有好多个区块,比如列表区块,但是他们代码结构又是一模一样的怎么弄?jade天生就是节约成本,节约时间的,mixin就是让代码块可以重用的函数   mixin lession p jade s ...

  10. Python多线程应用于自动化测试

    Python多线程应用于自动化测试 将多线程在测试巧妙地应用,确实会带来很多好处,并且这是充分利用机器资源执行高效率测试很好的方式 # -*- coding: utf-8 -*- import thr ...