CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Centos 7安装mysql数据库大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

 系统版本:系统是最小化安装 @查看系统版本 [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@H_675_5@

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

@查看系统版本
[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
@R_969_10586@l 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
@R_969_10586@l 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://code.js-code.com/article/p-bfanaylv-gk.html

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

大佬总结

以上是大佬教程为你收集整理的Centos 7安装mysql数据库全部内容,希望文章能够帮你解决Centos 7安装mysql数据库所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。