1.官网下载安装包,删除系统自带的mariadb,查到几个包,卸载几个包,总之得删除干净

[root@localhost Desktop]# yum list | grep mariadb
mariadb-libs.x86_64 :5.5.-.el7_0 @anaconda/7.1
[root@localhost Desktop]# yum remove mariadb-libs.x86_64 -y ==>删除这个包
[root@localhost Desktop]# yum list | grep mariadb  ==>已经查询不到mariadb
[root@localhost Desktop]# ls
mysql-5.7.-linux-glibc2.-x86_64.tar.gz    ==>这是安装包

2.创建用户和组以及将安装包移动到安装目录( /usr/local/ )下

[root@localhost Desktop]# groupadd mysql
[root@localhost Desktop]# useradd -g mysql mysql
[root@localhost Desktop]# mv mysql-5.7.-linux-glibc2.-x86_64.tar.gz /usr/local/
[root@localhost Desktop]# cd /usr/local/
[root@localhost local]# ls
bin games lib libexec sbin src
etc include lib64 mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz share

3.解压安装包,并文件重命名为mysql,删除安装包(也可以不删除,有强迫症的都会删),确定安装路径是在 /usr/local 目录下

[root@localhost local]# tar -zxvf mysql-5.7.-linux-glibc2.-x86_64.tar.gz
[root@localhost local]# ls
bin include libexec sbin
etc lib mysql-5.7.16-linux-glibc2.5-x86_64 share
games lib64 mysql-5.7.-linux-glibc2.-x86_64.tar.gz src
[root@localhost local]# mv mysql-5.7.-linux-glibc2.-x86_64 mysql ==>改名为mysql
[root@localhost local]# ls
bin games lib libexec mysql-5.7.-linux-glibc2.-x86_64.tar.gz share
etc include lib64 mysql sbin src
[root@localhost local]# rm mysql-5.7.-linux-glibc2.-x86_64.tar.gz
rm: remove regular file ‘mysql-5.7.-linux-glibc2.-x86_64.tar.gz’? y
[root@localhost local]# ls
bin etc games include lib lib64 libexec mysql sbin share src

4.编辑配置文件/ect/my.cnf,把/usr/local/mysql/support-files/my-defaults-cnf复制到/etc/目录下,并改名为my.cnf,也可以自己手动创建编辑

[root@localhost support-files]# cp -a my-default.cnf /etc/my.cnf 
[root@localhost local]# vim /etc/my.cnf
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
socket=/tmp/mysql.sock [mysqld]
#设置3306端口
port =
socket=/tmp/mysql.sock
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data
# 允许最大连接数
max_connections=
# 服务端使用的字符集默认为utf-8编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
max_allowed_packet=16M

5.初始化数据库

MySQL5.7.6之前版本都是用mysql_install_db这个命令

[root@localhost local]# ./mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

到了5.7版本后已经没有scripts这个目录,mysql_install_db也被移动到了bin目录下,5.7.6版本后这个命令已被弃用,若在5.7.6之后的版本用这个命令会报错

[root@localhost local]# ./mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
-- :: [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize ==>系统提示换成这个命令及参数
-- :: [ERROR] Child process: /usr/local/mysql/bin/mysqldterminated prematurely with errno=
-- :: [ERROR] Failed to execute /usr/local/mysql/bin/mysqld --bootstrap --datadir=/usr/local/mysql/data --lc-messages-dir=/usr/local/mysql/share --lc-messages=en_US --basedir=/usr/local/mysql
-- server log begin --
--10T05::.757607Z [Warning] --bootstrap is deprecated. Please consider using --initialize instead -- server log end --

5.7.6之后版本的初始化命令,在执行前要确保 数据库的 data 目录 是一个空目录,不让也会报错,处理方式是执行 rf 清空目录,报错信息如下

--10T11::.586149Z  [ERROR] --initialize specified but the data directory has files in it. Aborting.

开始初始化数据库

[root@localhost local]# ./mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ ==>5.7执行初始化命令
--10T11::.625023Z [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
--10T11::.625070Z [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
--10T11::.625074Z [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
--10T11::.454989Z [Warning] InnoDB: New log files created, LSN=
--10T11::.659920Z [Warning] InnoDB: Creating foreign key constraint system tables.
--10T11::.749779Z [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: fb994d89-fc6f-11e8-ab5f-4e052dd49fa2.
--10T11::.765740Z [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
--10T11::.766627Z [Note] A temporary password is generated for root@localhost: dsqO!0eNa>V2 ==>注意这个是初始的root密码

6.设置开机自动启动脚本

复制启动脚本到/etc/rc.d/init.d/ 目录下并命名为mysqld,确认这个脚本具备X权限,若无执行 chmod 加权限

[root@localhost local]# cp mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost local]# ll /etc/rc.d/init.d/mysqld
-rwxr-xr-x. root root Dec : /etc/rc.d/init.d/mysqld

把mysqld服务加入到系统服务

[root@localhost local]# chkconfig --add mysqld
[root@localhost local]# chkconfig --list | grep mysqld Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'. mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off ==>服务已生效

 

7.启动数据库服务

[root@localhost local]# service mysqld start
[root@localhost local]# service mysqld status

8.登入数据库修改密码,并设置允许远程登入

[root@localhost local]# /usr/local/mysql/bin/mysql -uroot -p'dsqO!0eNa>V2'
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
Server version: 5.7. Copyright (c) , , 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>

修改密码

mysql> SET PASSWORD FOR 'root'@localhost=PASSWORD('redhat');
Query OK, rows affected, warning (0.01 sec)

设置主机可以远程登入

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'redhat' WITH GRANT OPTION;
Query OK, rows affected, warning (0.00 sec) mysql> flush privileges; ==>刷新权限表

9.配置环境变量

[root@localhost local]# vim /etc/profile

# MySQL Environment Variable Settings
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin [root@localhost local]# source /etc/profile

10.配置防火墙

[root@localhost local]# firewall-cmd --permanent --add-port=/tcp
success
[root@localhost local]# firewall-cmd --reload
success

安装基本完成

mysql5.7版本tar包手动安装---redhat7.0的更多相关文章

  1. Centos7下安装postgresql(tar包形式安装)

    Centos7下安装postgresql(tar包形式安装) 1.官网下载地址: https://www.postgresql.org/ftp/source/ 2.将下载来tar包上传到linux服务 ...

  2. Eclipse4.4.2手动安装Veloeclipse-2.0.8

    引言:     新安装了Eclipse最新版本 4.4.2 Luna(月神),由于项目中使用到了模板引擎Velocity,所以想安装一个Velocity插件, 在网上找了一下,看到Google的vel ...

  3. MySQL5.7 基于二进制包的安装

    1.MySQL5.7安装注意事项 1.在MySQL5.7中mysql_install_db已经不再推荐使用,建议改成mysqld-initialize 完成实力初始化.(mysql_install_d ...

  4. MYSQL5.5源码包编译安装

    MYSQL5.5源码安装首先安装必要的库yum -y install gcc*###### 安装 MYSQL ######首先安装camke 一.支持YUM,则yum install -y cmake ...

  5. MYSQL5.7源码包编译安装

    Centos下用cmake编译安装MySQL 5.7安装依赖包yum -y install gcc gcc-c++ ncurses ncurses-devel cmake下载相应源码包cd /usr/ ...

  6. MYSQL5.6源码包编译安装

    linux下用cmake编译安装mysql-5.6.35cmake编译安装mysql的方法:#useradd -M mysql -s /sbin/nologin#yum install -y cmak ...

  7. Spyder清除Variable Explorer&&手动安装protobuf3.0(为了配置windows的python接口)

    输入:reset 选择:y PS:建议在windows下,安装anaconda32bit版本的,可以兼容更多第三方包.   Conda使用清华镜像 配置镜像 在conda安装好之后,默认的镜像是官方的 ...

  8. 手动安装MySQL8.0

    首先跟大家唠一唠家常,随着MySQL迅速的更新,MySQL突飞猛进已经更新到了8.0版本,那么它和我们之前用的5.X版本有什么明显的区别那? 首先给大家看下MySQL5.X自带表的查询速度 之后献上M ...

  9. mysql5.7版本yum安装---redhat7.0

    1.官网下载yum包 [root@test01 test]# wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch ...

随机推荐

  1. ECMAScript6 入门教程记录 变量的解构赋值

    (1)变量的解构赋值 基本用法:ES6 允许按照一定模式,从数组和对象中提取值,对变量进行赋值,这被称为解构(Destructuring). let a = 1; let b = 2; let c = ...

  2. c# 笔记cookie

    if (Request.Cookies["svpoint"] != null) { Request.Cookies[].s_SvcID.ToString(); } else { H ...

  3. MariaDB导入XXX.sql文件

    使用的 MariaDB5.5.52 开启数据库服务: systemctl start mariadb 要使用该脚本,登录数据, mysql -u root -p 根据提示输入你安装数据库时需设置密码, ...

  4. 2018-2019-2 网络对抗技术 20165305 Exp1 PC平台逆向破解

    2018-2019-2 网络对抗技术 20165305 Exp1 PC平台逆向破解 实验1-1直接修改程序机器指令,改变程序执行流程 先输入objdump -d 20165305pwn2查看反汇编代码 ...

  5. 【winform】serialPort 串口

    一. 1.串口通信简单实现 该来的总会来的,学做硬件的,串口这个东西必须得门清. 俗话说的好,不会做串口助手的电子工程师不是好程序员.

  6. redis 在 php 中的应用(string篇)

    本文为我阅读了 redis参考手册 之后结合 博友的博客 编写,注意 php_redis 和 redis-cli 的区别(主要是返回值类型和参数用法) 目录: string(字符串) SET SETN ...

  7. ASP.NET Core WebApi使用Swagger生成api

    引言 在使用asp.net core 进行api开发完成后,书写api说明文档对于程序员来说想必是件很痛苦的事情吧,但文档又必须写,而且文档的格式如果没有具体要求的话,最终完成的文档则完全取决于开发者 ...

  8. 论文笔记【三】A Deep Dive into Word Sense Disambiguation with LSTM

    深入理解LSTM词义消歧 Minh Le,Marten Postma,Jacopo Urbani和Piek Vossen 阿姆斯特丹自由大学语言,文学和传播系 阿姆斯特丹自由大学计算机科学系 摘要 基 ...

  9. 如何用Github删除repository

    第一步,登陆github,一定要点开要删除的repository,再选择相应的setting: 第二步,下拉选择,delete this repository 第三步,输入删除的仓库名,删除repos ...

  10. ELK学习笔记之ELK搜集OpenStack节点日志

    模板来自网络,模板请不要直接复制,先放到notepad++内调整好格式,注意缩进 部署架构 控制节点作为日志服务器,存储所有 OpenStack 及其相关日志.Logstash 部署于所有节点,收集本 ...