文档章节

Centos 7安装mysql数据库

诺岚
 诺岚
发布于 2017/08/24 17:15
字数 1186
阅读 74
收藏 0
点赞 0
评论 0

 系统版本:系统是最小化安装

@查看系统版本
[root@localhost ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core) 
@查看内核版本
[root@localhost ~]# cat /proc/version
Linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux 

安装包:mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz

下载地址:

官网: http://dev.mysql.com/downloads/mysql/

[BEGIN] 2017/8/24 16:49:51
Last login: Mon Aug  7 18:50:39 2017 from 10.2.202.39
--
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -g mysql -d /home/mysql mysql
[root@localhost ~]# mkdir /home/mysql/data
[root@localhost ~]# mkdir /home/mysql/log
[root@localhost ~]# cd /home/mysql
[root@localhost mysql]# vi /home/mysql/log/mariadb.log
-bash: [root@localhost: command not found
[root@localhost ~]# vi /home/mysql/log/mariadb.log
:wq
"/home/mysql/log/mariadb.log" [New] 0L, 0C written


[root@localhost ~]# cd /home/mysql/log/
[root@localhost log]# ll
total 0
-rw-r--r--. 1 root root 0 Aug  7 19:02 mariadb.log
[root@localhost log]# cd /home/mysql
[root@localhost mysql]# tar -xzvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
[root@localhost mysql]# cd mysql-5.7.19-linux-glibc2.12-x86_64
[root@localhost mysql-5.7.19-linux-glibc2.12-x86_64]# mv * /home/mysql/
[root@localhost mysql-5.7.19-linux-glibc2.12-x86_64]# cd ..
[root@localhost mysql]# rm -rf mysql-5.7.19-linux-glibc2.12-x86_64
[root@localhost mysql]# vi support-files/mysql.server

@在这里增加上路径
basedir=/home/mysql
@在这里增加上路径
datadir=/home/mysql/data
@按Esc退出编辑模式,输入:wq 保存退出
:wq



[root@localhost mysql]# vi /etc/my.cnf
@修改前
"/etc/my.cnf" 19L, 570C[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
# include all files from the config directory
!includedir /etc/my.cnf.d                                                           
datadir=/var/lib/mysq-- INSERT --l/home/mysql/datasql.sock/tmp/mysql.sock
character_set_server=utf8
init_connect='SET NAMES utf8'
[client]
default-character-set=utf8/mariadb.log/home/mysql/log/mariadb.lid/home/mysql/log//mariadb.pid:wq
"/etc/my.cnf" 22L, 652C written
@修改后:
[mysqld]
datadir=/home/mysql/data
socket=/tmp/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
character_set_server=utf8
init_connect='SET NAMES utf8'
[client]
default-character-set=utf8
[mysqld_safe]
log-error=/home/mysql/log/mariadb.log
pid-file=/home/mysql/log//mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
"/etc/my.cnf" 22L, 652C written


[root@localhost home]# cd /home/mysql/
[root@localhost mysql]# chown -R mysql:mysql .
@查询权限
[root@localhost mysql]# ll
total 625676
drwxr-xr-x.  2 mysql mysql      4096 Aug  7 19:05 bin
-rw-r--r--.  1 mysql mysql     17987 Jun 22 22:13 COPYING
drwxr-xr-x.  2 mysql mysql         6 Aug  7 19:00 data
drwxr-xr-x.  2 mysql mysql        52 Aug  7 19:05 docs
drwxr-xr-x.  3 mysql mysql      4096 Aug  7 19:05 include
drwxr-xr-x.  5 mysql mysql      4096 Aug  7 19:05 lib
drwxr-xr-x.  2 mysql mysql        24 Aug  7 19:02 log
drwxr-xr-x.  4 mysql mysql        28 Aug  7 19:05 man
-rw-r--r--.  1 mysql mysql 640650826 Aug  7 19:04 mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
-rw-r--r--.  1 mysql mysql      2478 Jun 22 22:13 README
drwxr-xr-x. 28 mysql mysql      4096 Aug  7 19:05 share
drwxr-xr-x.  2 mysql mysql        86 Aug  7 19:07 support-files
@初始化实例
[root@localhost mysql]# ./bin/mysqld --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --initialize
2017-08-07T11:09:24.645721Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-07T11:09:27.252970Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-08-07T11:09:27.519535Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-08-07T11:09:27.831349Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: e0e5a75a-7b60-11e7-bde3-000c2987bdd8.
2017-08-07T11:09:27.912800Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-08-07T11:09:27.914113Z 1 [Note] A temporary password is generated for root@localhost: +D<3syDc#s3<
@启动数据库
[root@localhost mysql]# ./support-files/mysql.server start
Starting MySQL. SUCCESS! @启动成功
[root@localhost mysql]# ./support-files/mysql.server stop
Shutting down MySQL.. SUCCESS! @停止数据库
@设置随机启动
[root@localhost mysql]#  cp /home/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# chmod 755 /etc/init.d/mysqld
[root@localhost mysql]# chkconfig --level 345 mysqld on
@启动数据库
[root@localhost mysql]# ./support-files/mysql.server start
Starting MySQL. SUCCESS! 


@更改初始密码
[root@localhost mysql]# ./bin/mysqladmin -uroot -p'.QQ7emrasrc0' password '123456'
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
@建软链接
[root@localhost mysql]# ln -s /home/mysql/bin/mysql /usr/bin/mysql
[root@localhost mysql]# mysql -uroot -p123456

mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> grant all on *.* to 'root'@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit
Bye
[root@localhost mysql]# 

 

学习安装来源参考于:http://blog.csdn.net/cryhelyxx/article/details/49757217

感谢:QQ:929679459 的远程协助帮忙处理,十分感谢

© 著作权归作者所有

共有 人打赏支持
诺岚
粉丝 0
博文 87
码字总数 143206
作品 0
广州
程序员
linux操作系统centos 7 安装MySQL数据库

linux操作系统centos 7 安装MySQL数据库 其实我第一次在linux下安装的时候,也没有安装成功,因为我是在centos 7 下安装的,centos 7 下默认安装的是mariadb数据库。所有在安装mysql前应该先...

zhaoliang1131 ⋅ 2016/07/29 ⋅ 0

Linux系统入门学习:在CentOS上安装phpMyAdmin

问题:我正在CentOS上运行一个MySQL/MariaDB服务,并且我想要通过网络接口来用phpMyAdmin来管理数据库。在CentOS上安装phpMyAdmin的最佳方法是什么? phpMyAdmin是一款以PHP为基础,基于Web的...

imzdx ⋅ 2015/11/11 ⋅ 0

源码安装lamp

在实际环境中我们经常根据自己所处的公司环境进行配置,适合自己公司的配置。下面我们来介绍如何进行编译安装 安装前提 在CentOS7 系统: 关闭iptables 将selinux设置为disabled apr-1.6.2.ta...

Joah_Li ⋅ 2017/10/18 ⋅ 0

CentOS以RPM方式安装MYSQL

CentOS5.6以RPM方式安装MySQL5.6 1.检查MySQL及相关RPM包,是否安装,如果有安装,则移除(rpm –e 名称) 如果卸载不掉提示异常,则可以强制卸载依赖 2.下载Linux对应的RPM包,如:CentOS6...

3kqing ⋅ 2016/06/27 ⋅ 0

CentOS7安装通用二进制格式MariaDB 10.2.8

什么是MariaDB MariaDB 是MySql的一个分支。 了解一下数据库的发展历史,我们知道,MySql数据库不但二次易主,而且还被打入了冷宫(先被sun收购,然后sun被Oracle收购)。因为Oracle有自己的数...

Eumenides_s ⋅ 2017/09/27 ⋅ 0

Openfire+CentOS+MySQL那些事

Openfire+CentOS+MySQL 和上篇类似,这篇主要说说CentOS 安装第一步,官网下载Openfire安装包http://www.igniterealtime.org/downloads/index.jsp。Windows下openfire404.exe的,Linux下ope...

AmosWang ⋅ 2016/12/10 ⋅ 0

MySQL5.6 yum安装

1、安装依赖库 yum -y update 2、添加MySQL YUM仓库 wget rpm -Uvh mysql-community-release-el5-5.noarch.rpm 3、添加/etc/yum.repos.d/mysql-community.repo vim /etc/yum.repos.d/mysql-......

fireweb ⋅ 2015/06/16 ⋅ 0

CentOS 7 安装MySQL

说说在CentOS 7 下安装MySQL数据库的过程,希望对大家有所帮助。 从MySQL官网下载源再用yum安装: wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm rpm -ivh mysq...

动听的椰子 ⋅ 2016/01/01 ⋅ 0

使用RPM包离线安装MariaDB 10.0.20 , 基于CentOS 6.6-x86-64

使用RPM包[离线]安装 MariaDB 10.0.20,基于CentOS 6.6-x86-64 Minimal 湘中朱生 2015-07-01 于深圳福田 QQ: 872007255 MariaDB交流群: 198111730 文档说明: 1. 网上有很多关于MariaDB/Mysql...

湘中朱生 ⋅ 2015/07/04 ⋅ 1

Zabbix监控系列之环境搭建——LAMP

好久没有发表博文了,感觉有点对不住51CTO和自己,嘿嘿~~ 近期公司要安装监控服务器,正好趁此机会,将流程系统梳理下,制成文档,分享众人!我觉得这事儿利人利己,也便于自己以后复习使用!...

longsir1989 ⋅ 2016/08/03 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

开启Swarm集群以及可视化管理

在搭建的两台coreos服务器上开启swarm集群 前置条件: docker均开启2375端口 同一个局域网内 主服务器上安装Portainer容器 安装Portainer容器执行: docker run -d -p 9000:9000 --restart=a...

ykbj ⋅ 2分钟前 ⋅ 0

单例设计模式

1、单例模式确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例 2、饿汉式单例类 在这个类被加载时,静态变量instance会被初始化,此时类的私有构造子会被调用 饿汉式是典型...

职业搬砖20年 ⋅ 7分钟前 ⋅ 0

前端基础(四):前端国际规范收集

字数:1142 阅读时间:5分钟 前言 由于前端技术的灵活性和杂乱性,导致网上的许多解决方案不够全面甚至是完全错误,容易起到误导作用。所以,我对搜索到的解决方案往往是存疑态度。那么,如何...

老司机带你撸代码 ⋅ 9分钟前 ⋅ 0

Failed to open/create Network-VirtualBox Host-Only

虚拟机版本 : Oracle Vm VirtualBox 5.2.12 报错时机:开网卡二,重启虚拟机报错 "Failed to open/create the internal network 'HostInterfaceNetworking-VirtualBox Host-Only Ethernet Ada......

p至尊宝 ⋅ 13分钟前 ⋅ 0

三分钟学会如何在函数计算中使用 puppeteer

摘要: 使用 puppeteer 结合函数计算,可以快速的构建弹性的服务完成各种功能,包括:生成网页截图或者 PDF、高级爬虫,可以爬取大量异步渲染内容的网页、模拟键盘输入、表单自动提交、登录网...

阿里云云栖社区 ⋅ 16分钟前 ⋅ 0

springMVC接收表单时 Bean对象有Double Int Char类型的处理

前台ajax提交表单price为double类型 后台controller就介绍不到 400错误 前台 实体类: public class ReleaseMapIconConfig{ private String id; private long maxValue; private long minVal......

废柴 ⋅ 18分钟前 ⋅ 0

ZOOKEEPER安装

工作需要在ubuntu上配置了一个zookeeper集群,有些问题记录下来。 1. zookeeper以来java,所以首先要安装java。但是ubuntu系统有自带的jdk,需要通过命令切换java版本: $ sudo update-alter...

恰东 ⋅ 21分钟前 ⋅ 0

linux 进程地址空间的一步步探究

我们知道,在32位机器上linux操作系统中的进程的地址空间大小是4G,其中0-3G是用户空间,3G-4G是内核空间。其实,这个4G的地址空间是不存在的,也就是我们所说的虚拟内存空间。 那虚拟内存空间...

HelloRookie ⋅ 21分钟前 ⋅ 0

myatis #{}与${}区别及原理

https://blog.csdn.net/wo541075754/article/details/54292751

李道福 ⋅ 24分钟前 ⋅ 0

三分钟学会如何在函数计算中使用 puppeteer

摘要: 使用 puppeteer 结合函数计算,可以快速的构建弹性的服务完成各种功能,包括:生成网页截图或者 PDF、高级爬虫,可以爬取大量异步渲染内容的网页、模拟键盘输入、表单自动提交、登录网...

猫耳m ⋅ 25分钟前 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部