一、检查是否安装了mysql和mariadb,若已经安装就需要卸载。

  1. [root@localhost ~]# rpm -qa|grep mariadb   // 查询出来已安装的mariadb
  2. [root@localhost ~]# rpm -e --nodeps 文件名   // 卸载mariadb,文件名为上述命令查询出来的文件
    [root@localhost ~]# rm /etc/my.cnf      //删除配置文件

二、添加mysql用户及用户组

  1. [root@localhost ~]# groupadd mysql //创建mysql用户组
  2. [root@localhost ~]# useradd -g mysql mysql //创建mysql用户,并添加到mysql用户组

三、解压文件,并移动到指定的目录下

  1. [root@localhost ~]# tar -zvxf mysql-5.7.-linux-glibc2.-x86_64.tar.gz
  2. [root@localhost ~]# mv 解压出来的文件夹名 mysql
  3. [root@localhost ~]# mv mysql /usr/local/

四、创建配置文件

  1. [root@localhost support-files]# vim /etc/my.cnf
  2. #通过vim编辑器编辑my.cnf代码如下:

[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /tmp/mysql.sock
character-set-server=utf8

log-error = /usr/local/mysql/data/mysqld.log
pid-file = /usr/local/mysql/data/mysqld.pid

五、初始化数据库

  1. [root@localhost ~]# cd /usr/local/mysql/bin/
  2. [root@localhost bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

六、查看初始默认密码

  1. [root@localhost bin]# cat /usr/local/mysql/data/mysqld.log
  2. --05T07::.263392Z [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  3. --05T07::.263457Z [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.
  4. --05T07::.263462Z [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
  5. --05T07::.961752Z [Warning] InnoDB: New log files created, LSN=
  6. --05T07::.039265Z [Warning] InnoDB: Creating foreign key constraint system tables.
  7. --05T07::.095290Z [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: b858de41--11e9-84f3-00505681edfc.
  8. --05T07::.096413Z [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  9. --05T07::.096953Z [Note] A temporary password is generated for root@localhost: kXJh+_RMu52K

七、将启动脚本放到开机初始化目录

  1. [root@localhost ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

八、启动mysql

  1. [root@localhost ~]# service mysql start
  2. Starting MySQL. SUCCESS!

九、使用root账号和默认密码登录mysql

  1. [root@localhost ~]# cd /usr/local/mysql/bin/
  2. [root@localhost bin]# ./mysql -uroot -p
  3. Enter password:
  4. Welcome to the MySQL monitor. Commands end with ; or \g.
  5. Your MySQL connection id is
  6. Server version: 5.7.
  7.  
  8. Copyright (c) , , Oracle and/or its affiliates. All rights reserved.
  9.  
  10. Oracle is a registered trademark of Oracle Corporation and/or its
  11. affiliates. Other names may be trademarks of their respective
  12. owners.
  13.  
  14. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  15.  
  16. mysql>

十、修改root密码

  1. mysql> set password=password('root');
  2. Query OK, rows affected, warning (0.00 sec)
  3.  
  4. mysql> grant all privileges on *.* to root@'%' identified by '';
  5. Query OK, rows affected, warning (0.01 sec)
  6.  
  7. mysql> flush privileges;
  8. Query OK, rows affected (0.00 sec)

十一、添加远程访问权限

  1. mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;
  2. Query OK, rows affected, warning (0.00 sec)

十二、重启mysql

  1. [root@localhost bin]# service mysql restart
  2. Shutting down MySQL.. SUCCESS!
  3. Starting MySQL. SUCCESS!

centos7 安装 mysql5.7.25的更多相关文章

  1. CentOS6.3 编译安装LAMP(3):编译安装 MySQL5.5.25

    所需源码包: /usr/local/src/MySQL-5.5.25/cmake-2.8.8.tar.gz /usr/local/src/MySQL-5.5.25/mysql-5.5.25.tar.g ...

  2. Centos7 安装 MySQL5.7

    Centos7 安装 MySQL5.7 一.环境介绍 1.安装包版本介绍 MySQL 有三种安装方式:RPM安装.二进制包安装.源码包安装.我们这篇文章以二进制方式安装MySQL 软件名称 版本 系统 ...

  3. centos7安装mysql5.7.19及配置远程连接

    centos7安装mysql5.7.19及配置远程连接------https://blog.csdn.net/Lh19931122/article/details/77996213

  4. CentOS7.x安装MySQL5.7.25

    mysql 5.7下载地址 社区版下载地址:https://dev.mysql.com/downloads/mysql/ 可能会有变动 找到5.7版本, 注:源码安装需要用到下面的包,可以先忽略,我安 ...

  5. Centos7二进制文件安装MySQL5.7.25

    1.删除centos系统自带的mariadb数据库防止发生冲突 rpm -qa|grep mariadb rpm -e mariadb-libs --nodeps 2.安装libaio库 yum -y ...

  6. Centos7安装Mysql5.7方法总结 - 实操手册

    Centos7.x版本下针对Mysql的安装和使用多少跟之前的Centos6之前版本有所不同的,废话就不多赘述了,下面介绍下在centos7.x环境里安装mysql5.7的几种方法:一.yum方式安装 ...

  7. centos7 安装mysql5.7及配置

    一.Mysql 各个版本区别:1.MySQL Community Server 社区版本,开源免费,但不提供官方技术支持.2.MySQL Enterprise Edition 企业版本,需付费,可以试 ...

  8. Linux学习第三步(Centos7安装mysql5.7数据库)

    版本:mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar 前言:在linux下安装mysql不如windows下面那么简单,但是也不是很难.本文向大家讲解了如何在Cent ...

  9. Centos7安装mysql-5.7.19

    Centos7安装Mysql 一 mysql下载 地址: https://dev.mysql.com/downloads/mysql/#downloads 二 在centos7上创建安装文件存放.解压 ...

随机推荐

  1. MySQL 快速添加百万条数据

    需要向数据库添加100W条测试数据,直接在普通表中添加速度太慢,可以使用内存表添加,然后将内存表数据复制到普通表 创建表 # 内存表 DROP TABLE IF EXISTS `test_memory ...

  2. [转帖]编写shell脚本所需的语法和示例

    编写shell脚本所需的语法和示例 https://blog.csdn.net/CSDN___LYY/article/details/100584638 在说什么是shell脚本之前,先说说什么是sh ...

  3. 以Integer类型传参值不变来理解Java值传参

    最近在写代码的时候出了一个错误,由于对值引用理解的不深,将Integer传入方法中修改,以为传入后直接修改Integer中的值就不用写返回值接收了,虽然很快发现了问题,但还是来总结一下 首先是代码: ...

  4. 【转】用VMware 8安装Ubuntu 12.04详细过程(图解)

    图解演示环境版本: 本机系统: WIN7 虚拟机:VMware Workstation 8 (英文版) 安装目标:Ubuntu Desktop 12.04 LTS  (请点击这里)先下载好iso镜像文 ...

  5. Django学习——用户自定义models问题解决

    一.问题在Django中使用自定义的model的时候会出现下面的错误 ERRORS: auth.User.groups: (fields.E304) Reverse accessor for 'Use ...

  6. 上下文的哲学思考:上下文=环境 & 上下文=对象+行为+环境

    事物的存在和运行所依赖的全部资源(能够看到和使用的一切)(环境). 上下文研究的是一个时段内,多个主体.对象在历次操作活动时,在空间的信息投射. 上下文是事物存在和生存活动的气泡,气泡消失,事物消失. ...

  7. 关于django模型里面的__str__和__unicode__

    python3    django模型里面 使用 __str__  如果使用__unicode__是无效的 简而言之,就是__str__和__unicode__都是为了再管理站点中加载这个表时想显示什 ...

  8. 易百教程人工智能python补充-NLTK包

    自然语言处理(NLP)是指使用诸如英语之类的自然语言与智能系统进行通信的AI方法. 如果您希望智能系统(如机器人)按照您的指示执行操作,希望听取基于对话的临床专家系统的决策时,则需要处理自然语言. N ...

  9. git操作:查看分支、删除本地分支和远程分支

    1.查看本地分支:git branch 2.查看远程分支:git branch -r 或 git branch --remote 3.查看本地和远程的所有分支:git branch -a 4.删除本地 ...

  10. Centos下安装LoadRunner负载机

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAd0AAADfCAIAAAA84J6GAAAgAElEQVR4nJzb93cbR6In+uK/8v6Fd8