系统版本:系统是最小化安装
@查看系统版本[root@localhost ~]# cat /etc/os-releaseNAME="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-releaseCentOS Linux release 7.2.1511 (Core) @查看内核版本[root@localhost ~]# cat /proc/versionLinux 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 -aLinux 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
安装包:
下载地址:
官网:
[BEGIN] 2017/8/24 16:49:51Last 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]# lltotal 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/mysqlsocket=/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-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.logpid-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.sockcharacter_set_server=utf8init_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/datasocket=/tmp/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-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/Systemdcharacter_set_server=utf8init_connect='SET NAMES utf8'[client]default-character-set=utf8[mysqld_safe]log-error=/home/mysql/log/mariadb.logpid-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]# lltotal 625676drwxr-xr-x. 2 mysql mysql 4096 Aug 7 19:05 bin-rw-r--r--. 1 mysql mysql 17987 Jun 22 22:13 COPYINGdrwxr-xr-x. 2 mysql mysql 6 Aug 7 19:00 datadrwxr-xr-x. 2 mysql mysql 52 Aug 7 19:05 docsdrwxr-xr-x. 3 mysql mysql 4096 Aug 7 19:05 includedrwxr-xr-x. 5 mysql mysql 4096 Aug 7 19:05 libdrwxr-xr-x. 2 mysql mysql 24 Aug 7 19:02 logdrwxr-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 READMEdrwxr-xr-x. 28 mysql mysql 4096 Aug 7 19:05 sharedrwxr-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 --initialize2017-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=457902017-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 startStarting MySQL. SUCCESS! @启动成功[root@localhost mysql]# ./support-files/mysql.server stopShutting 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 startStarting 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 -p123456mysql: [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 4Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.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> exitBye[root@localhost mysql]#
学习安装来源参考于:
感谢:QQ:929679459 的远程协助帮忙处理,十分感谢