文档章节

Centos 7安装mysql数据库

诺岚
 诺岚
发布于 2017/08/24 17:15
字数 1224
阅读 111
收藏 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 ~]# vim /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]# vim support-files/mysql.server

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



[root@localhost mysql]# vim /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 的远程协助帮忙处理,十分感谢

© 著作权归作者所有

诺岚
粉丝 1
博文 109
码字总数 193210
作品 0
广州
程序员
私信 提问
linux操作系统centos 7 安装MySQL数据库

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

zhaoliang1131
2016/07/29
0
0
Linux系统入门学习:在CentOS上安装phpMyAdmin

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

imzdx
2015/11/11
0
0
Linux服务器上简单搭建wordpress

一、登录linux服务器 选用CentOS 系统 (最好选用centOS 7版本以下的,不然进行下面的yum install安装的时候mysql-server可能会错误) 二、配置环境 (1)安装apache php mysql软件 在CentO...

1533816606116580
2018/08/25
0
0
MMM+Amoeba搭建MySQL高可用负载均衡群集

MySQL的主从复制和MySQL的读写分离两者有着紧密联系,首先要部署主从复制,只有主从复制完成了,才能在此基础上进行数据的读写分离。MySQL的读写分离就是只在主服务器上写,只在从服务器上读...

cchenyz
2018/07/22
0
0
源码安装lamp

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

Joah_Li
2017/10/18
0
0

没有更多内容

加载失败,请刷新页面

加载更多

JWT学习总结

官方 https://jwt.io 英文原版 https://www.ietf.org/rfc/rfc7519.txt 或 https://tools.ietf.org/html/rfc7519 中文翻译 https://www.jianshu.com/p/10f5161dd9df 1. 概述 JSON Web Token(......

冷基
59分钟前
3
0
AOP的学习(1)

AOP 理解AOP编程思想(面向方法、面向切面) spring AOP的概念 方面 -- 功能 目标 -- 原有方法 通知 -- 对原有方法增强的方法 连接点 -- 可以用来连接通知的地方(方法) 切入点 -- 将用来插入...

太猪-YJ
今天
4
0
一张图看懂亮度、明度、光度、光亮度、明亮度

亮度、明度、光亮度,Luminance和Brightness、lightness其实都是一个意思,只是起名字太难了。 提出一个颜色模型后,由于明度的取值与别人的不同,为了表示区别所以就另想一个词而已。 因此在...

linsk1998
昨天
8
0
Python应用:python链表示例

前言 python链表应用源码示例,需要用到python os模块方法、函数和类的应用。 首先,先简单的来了解下什么是链表?链表是一种物理存储单元上非连续、非顺序的存储结构,数据元素的逻辑顺序是...

python小白1
昨天
4
0
Source Insight加载源码

Source Insight是一个图形化的源代码查看工具(当然也可以作为编译工具)。如果一个项目的源代码较多,此工具可以很方便地查找到源代码自建的依赖关系。 1.创建工程 下图为Snort源代码的文件...

天王盖地虎626
昨天
5
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部