文档章节

Centos 7安装mysql数据库

诺岚
 诺岚
发布于 2017/08/24 17:15
字数 1224
阅读 92
收藏 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 的远程协助帮忙处理,十分感谢

© 著作权归作者所有

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

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

zhaoliang1131
2016/07/29
0
0
Linux服务器上简单搭建wordpress

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

1533816606116580
08/25
0
0
Linux系统入门学习:在CentOS上安装phpMyAdmin

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

imzdx
2015/11/11
0
0
MMM+Amoeba搭建MySQL高可用负载均衡群集

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

cchenyz
07/22
0
0
CentOS7安装通用二进制格式MariaDB 10.2.8

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

Eumenides_s
2017/09/27
0
0

没有更多内容

加载失败,请刷新页面

加载更多

转:XMLHttpRequest2 新技巧

”XMLHttpRequest 的异步调用网上找的例子运行没问题,但稍微改了一点点就报错”InvalidStateError: XMLHttpRequest has an invalid context“。断断续续 搞了3天终于通了,可以接收二进制文...

SamXIAO
18分钟前
0
0
=====D服务器定时任务=====

Linux定时任务 crontab linux系统是有cron这个系统服务来控制的,Liunx系统上包含很多的计划性工作,使用者自己可以设置计划任务,所以linux系统提供了使用者控制计划任务的命令 crontab的启...

覃光林
27分钟前
0
0
xilinx资源

本系列教学视频由赛灵思高级战略应用工程师带领你:从零开始,一步步深入 掌握 HLS 以及 UltraFAST 设计方法,帮助您成为系统设计和算法加速的大拿! http://www.eetrend.com/topics/2018-0...

whoisliang
39分钟前
2
0
企业级开源四层负载均衡解决方案--LVS

网盘链接 企业级开源四层负载均衡解决方案--LVS 本课程将在Linux环境下,学习配置使用LVS,对Web集群和MySQL集群进行负载均衡,并结合利用Keepalived实现负载均衡器的高可用,实现对后端Rea...

qq__2304636824
48分钟前
3
0
Windows上安装Spacemacs

emacs安装 下载地址emacs 安装比较简单,解压后执行\bin\addpm.exe即可 emacs配置 emacs的默认配置文件路径和.emacs.d文件夹都是在Windows主目录下的 C:\Users\Administrator\AppData\Roami...

yxmsw2007
今天
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部