#####1,安装前首先确认系统版本

[root@bogon:~]# cat /etc/redhat-release
CentOS release 6.6 (Final)
[root@bogon:~]# uname -r
2.6.32-504.el6.x86_64
[root@bogon:~]# uname -m
x86_64
2,排除系统中存在的mysql和mariadb
[root@bogon:~]# rpm -qa|egrep "mysql|mariadb"
mysql-libs-5.1.73-3.el6_5.x86_64
[root@bogon:~]# rpm -e --nodeps mysql-libs-5.1.73-3.el6_5.x86_64
#包括/var/lib/mysql下的文件也需要清空(可以通过find / -name "mysql"来查找)
3,从官网下载二进制安装包,创建存放软件包的文件,并通过rsync把软件从本地上传到服务器指定位置,并用md5校验文件的准确性
[root@bogon:/home/hejian/tools]# rsync -avzP -e "ssh -p 22" hejian@192.168.0.103:/Users/hejian/Desktop/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz .
[root@bogon:/home/hejian/tools]# md5sum mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
d241f5dd6527cf1f9ff39449538c1eb1 mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
4,把mysl解压到指定文件夹,并创建软链接
[root@bogon:/home/hejian/tools]# mkdir -p /application
[root@bogon:/home/hejian/tools]# tar -xf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz -C /application/
5,创建mysql用户,并给mysql文件夹授权
[root@bogon:/application]# useradd -s /sbin/nologin -M mysql
[root@bogon:/application]# chown -R mysql.mysql /application/mysql
6,创建my-default.cnf配置文件,并拷贝到/etc下

从5.7.18版本开始,已经不提供my-default.cnf文件

[client]
port = 3306
socket = /tmp/mysql.sock [mysqld] #设置3306端口
port = 3306 #设置socke文件所在目录
socket=/tmp/mysql.sock # 设置mysql的安装目录
basedir=/application/mysql # 设置mysql数据库的数据的存放目录
datadir=/application/mysql/data # 允许最大连接数
max_connections=200 #SQL数据包发送的大小
max_allowed_packet = 128M # 服务端使用的字符集默认为latin1字符集
character-set-server=utf8 # 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB [mysqld_safe]
#数据库错误日志文件
log_error =/application/mysql/data/error.log
[root@bogon:/application/mysql/support-files]# cp my-default.cnf /etc/my.cnf
7,对mysql进行初始化,会5.7以后用--initialize来初始化,并最后生成一个随机密码
[root@bogon:/application/mysql]# ./bin/mysqld --initialize --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
2019-04-11T11:51:03.883359Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-04-11T11:51:04.624279Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-04-11T11:51:04.714769Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-04-11T11:51:04.792980Z 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: 1602c2e3-5c50-11e9-98d6-000c2933615e.
2019-04-11T11:51:04.794419Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-04-11T11:51:04.798256Z 1 [Note] A temporary password is generated for root@localhost: &jKQaE6rE77b
8,设置加密连接
[root@bogon:/application/mysql]# /application/mysql/bin//mysql_ssl_rsa_setup
Generating a 2048 bit RSA private key
..+++
..............+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
........................................+++
.......................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
..............................+++
..............................................................................................................+++
writing new private key to 'client-key.pem'
-----
9,配置系统的方式启动MySQL,并设置开机自启动
[root@bogon:/application/mysql]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld

由于mysql默认的安装路径是/usr/local/mysql,需要对mysqld脚本下的文件做个替换

[root@bogon:/application/mysql]# sed -i 's#/usr/local#/application#g' /etc/init.d/mysqld

然后启动mysql,并设置开机自启动

[root@bogon:/application]# /etc/init.d/mysqld start
[root@bogon:/application]# netstat -tunlp|grep mysqld
tcp 0 0 :::3306 :::* LISTEN 25092/mysqld [root@bogon:/application]# chkconfig mysqld on
[root@bogon:/application]# chkconfig --list|grep mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
10,配置环境变量
vim /etc/profile
PATH="/application/mysql/bin:$PATH"
source /etc/profile
11,然后输入第7步生成的随机密码,就可以正常登录了
[root@bogon:/application]#  mysql -hlocalhost -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.25 Copyright (c) 2000, 2019, 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> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password=password("123456");
mysql> flush privileges;

mysql成功安装完毕!

最新文章

  1. Poco::JSON::Array 中object 设置preserveInsertionOrder 时,stringify出错-->深入解析
  2. 格式化input输入内容(金额)
  3. partial class的使用范围
  4. JAVA并发编程
  5. WINDOWS窗口风格 WS_OVERLAPPEDWINDOW
  6. 【leetcode】Reverse Integer
  7. 第十九篇:提高SOUI应用程序渲染性能的三种武器
  8. javascript的异步编程方法
  9. [c++][语言语法]函数模板和模板函数 及参数类型的运行时判断
  10. python中使用zip函数出现<zip object at 0x02A9E418>
  11. UIBezierPath 的使用介绍
  12. web app 页面旋转整体样式问题
  13. C#解leetcode:119. Pascal's Triangle II
  14. script 两则
  15. 关于IE浏览器的一些思路
  16. JS中的单引号和双引号
  17. OpenCV——色调映射
  18. 基于.net core实现项目自动编译、并生成nuget包
  19. windows下gitbash安装教程
  20. 论文笔记:Auto-DeepLab: Hierarchical Neural Architecture Search for Semantic Image Segmentation

热门文章

  1. MongoDB简介、特点、原理、使用场景、应用案例
  2. linux下Qt程序编译运行
  3. android的数据与访问(2)-delphi xe7如何存取我的app配置参数文件?
  4. HDU 1704 Rank
  5. Struts简单介绍
  6. UVa 11466 - Largest Prime Divisor
  7. keyboard键盘demo
  8. VIM中括号的自动补全与删除
  9. ubuntu修改capslock键,单独使用为esc,组合使用时为ctrl+
  10. 使用register_chrdev注册字符设备