centos7 安装 mysql5.6(mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz)
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)的更多相关文章
- CentOS7安装MySQL5.7及Tomcat8.5
在CentOS7服务器上部署FR项目应用 一.安装CentOS-7_x86_64 1.CentOS7:带GUI的服务器(FTP服务器.JAVA平台.兼容性程序库.开发工具.安全性工具.系统管理工具): ...
- 搭建MHA环境【2】安装mysql-5.6 + mysql复制
本例中mysql的安装方式选用了二进制包安装方案.mysql复制用半同步复制方案 [1]安装mysql-5.6.31 要在所有的数据节点上都安装上mysql,安装方式大致相同,所以我这里就不重复写多次 ...
- Centos7 安装 MySQL5.7
Centos7 安装 MySQL5.7 一.环境介绍 1.安装包版本介绍 MySQL 有三种安装方式:RPM安装.二进制包安装.源码包安装.我们这篇文章以二进制方式安装MySQL 软件名称 版本 系统 ...
- linux centos7 安装mysql-5.7.17教程(图解)
1系统约定安装文件下载目录:/data/softwareMysql目录安装位置:/usr/local/mysql数据库保存位置:/data/mysql日志保存位置:/data/log/mysql 2下 ...
- 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:// ...
- centos7安装mysql5.7.19及配置远程连接
centos7安装mysql5.7.19及配置远程连接------https://blog.csdn.net/Lh19931122/article/details/77996213
- centos7 安装mysql5.7(二进制安装)
一.卸载默认安装的mariadb [root@localhost ~]# yum remove mariadb* -y 二.添加mysql用户 [root@localhost ~]# useradd ...
- centos7 安装 mysql5.7.25
一.检查是否安装了mysql和mariadb,若已经安装就需要卸载. [root@localhost ~]# rpm -qa|grep mariadb // 查询出来已安装的mariadb [root ...
- centos7安装mysql5.5.62
mysql是我们最常用的开源的关系型数据库,mysql不同版本有时候安装的方式也不尽相同,下面梳理一下mysql5.5.62版本的安装 1.下载mysql5.5.62,URL:https://down ...
随机推荐
- 怎样用sql语句复制表table1到表table2的同时复制主键
原文:怎样用sql语句复制表table1到表table2的同时复制主键 在从table1表复制到table2的时候,我们会用语句: select * into table2 from table1 但 ...
- office2019激活码 最新各个版本激活码
office2019专业版激活码 激活秘钥 一.office2019激活6月更新 [Key]:F4QWT-NMMKH-XPTV9-W9HFB-B4JCQ [剩余次数:900000+] office20 ...
- Java数据结构总述
array list map set 链表..array 和list类似,增删慢,读取快,list长度可变,array长度固定, 链表增删快的list set 是一个没有重复数据的集合 map 是一个 ...
- Linux报错排解
1.Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registe ...
- CentOS 7安装Hadoop集群
准备三台虚拟机,ip分别为192.168.220.10(master).192.168.220.11(slave1).192.168.220.12(slave2) 准备好jdk-6u45-linux- ...
- *p 和p[i] 区别
注意:*(arr+ n -1)指向的 是原来&a[n-1]是个地址 与arr[n-1]不同 !!重点!
- Java&Selenium数据驱动【DataProvider+TestNG+Array】
Java&Selenium数据驱动[DataProvider+TestNG+Array] package testNGWithDataDriven; import java.util.conc ...
- [转载]Java 应用性能调优实践
Java 应用性能调优实践 Java 应用性能优化是一个老生常谈的话题,笔者根据个人经验,将 Java 性能优化分为 4 个层级:应用层.数据库层.框架层.JVM 层.通过介绍 Java 性能诊断工具 ...
- IdentityServer(二)客户端授权模式
前言 客户端授权模,客户端直接向Identity Server申请token并访问资源.客户端授权模式比较适用于服务之间的通信. 搭建Identity服务 新建名为 IdentityServer 的W ...
- exception about Kernel Panic // dirperm1 breaks the protection by the permission bits on the lower branch
问题描述: 1. K8S集群有一个worker,经常磁盘满,然后导致服务异常. 2. 查看/var/log/syslog, 发现非常多的异常如下: 1568405.455565] docker0: p ...