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. MySQL存储的字段是不区分大小写的,你知道吗?

    做一个积极的人 编码.改bug.提升自己 我有一个乐园,面向编程,春暖花开! 00 简单回顾 之前写过一篇关于mysql 对表大小写敏感的问题,其实在mysql中字段存储的内容是不区分大小写的,本篇进 ...

  2. Spring Boot 使用 @Scheduled 注解创建定时任务

    在项目开发中我们经常需要一些定时任务来处理一些特殊的任务,比如定时检查订单的状态.定时同步数据等等. 在 Spring Boot 中使用 @Scheduled 注解创建定时任务非常简单,只需要两步操作 ...

  3. git命令 撤销文件修改

    git checkout . #本地所有修改的.没有的提交的,都返回到原来的状态 git checkout src/views/useChapter.vue #撤销项目目录 src/views/文件夹 ...

  4. React/事件系统

    React基于虚拟DOM实现了一个合成事件层,我们所定义的事件处理器会接收到一个合成事件对象的实例事件处理. 并且所有事件都自动绑定在最外层上.如果需要访问原生事件对象,可以使用nativeEvent ...

  5. cli中webpack的配置详解

    一.前言 vue-cli是构建vue单页应用的脚手架,输入一串指定的命令行从而自动生成vue.js+wepack的项目模板.这其中webpack发挥了很大的作用,它使得我们的代码模块化,引入一些插件帮 ...

  6. Java 面向对象(一)面向对象思想

    一.面向对象思想 1.概述 Java语言是一种面向对象的程序设计语言,而面向对象思想是一种程序设计思想,我们在面向对象思想的指引下,使用Java语言去设计.开发计算机程序. 这里的对象泛指现实中一切事 ...

  7. deep_learning_Github_初学者教程

    Github_link_from:https://github.com/lawlite19/MachineLearning_Python 机器学习算法Python实现 目录 机器学习算法Python实 ...

  8. [Selenium3+python3.6]自动化测试2-入门

    参考http://www.cnblogs.com/yoyoketang/p/6123890.html #coding=utf-8 #Import webdriver time module from ...

  9. excel单元格数据与文本框数据同步

    Private Sub Worksheet_SelectionChange(ByVal Target As Range) ActiveSheet.Shapes().TextFrame2.TextRan ...

  10. 查看python和NumPy版本和安装路径

    记录查看Python和NumPy版本以及路径的几条命令 # 查看Python版本及路径 python -V python -c "import sys;print(sys.executabl ...