当前位置: 首页 > news >正文

mysql5.7二进制编译包的安装

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

mysql5.7的二进制编译包安装方法与5.6版本有些地方不同,下面将安装方法记录,方便后期查看

  • 解压并移动目录至/usr/local,重命名为mysql5.7
[root@localhost src]# tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

[root@localhost src]# mv mysql-5.7.17-linux-glibc2.5-x86_64 ../mysql5.7
  • 创建目录,修改权限
[root@localhost mysql5.7]# mkdir /data/mysql5.7/
[root@localhost mysql5.7]# chown -R mysql.mysql /data/mysql5.7/
  • 初始化
[root@localhost mysql5.7]# ./bin/mysqld --initialize --user=mysql --datadir=/data/mysql5.7
2017-12-14T14:18:32.479547Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-12-14T14:18:32.479648Z 0 [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.
2017-12-14T14:18:32.479655Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2017-12-14T14:18:32.479775Z 0 [ERROR] Error message file '/usr/local/mysql/share/english/errmsg.sys' had only 886 error messages,
                    but it should contain at least 1081 error messages.
                    Check that the above file is the right version for                     this program!
2017-12-14T14:18:44.095382Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-12-14T14:18:48.210236Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-12-14T14:18:48.278351Z 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: b38a0c90-e0d9-11e7-97da-000c29d081f5.
2017-12-14T14:18:48.700210Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-12-14T14:18:48.703111Z 1 [Note] A temporary password is generated for root@localhost: xTA5l2(ATjof

最后这串字符"xTA5l2(ATjof"是mysql数据库初始化的root密码
  • 创建密钥
[root@localhost mysql5.7]# ./bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql5.7/
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'
-----

  • 修改配置文件(这里原本已经有/etc/my.cnf了,后续直接指定新的配置文件)
[root@localhost mysql5.7]# cp support-files/my-default.cnf /etc/my7.cnf
[root@localhost mysql5.7]# vi /etc/my7.cnf 
修改 basedir和datadir参数即可
  • 命令行模式启动mysql5.7
[root@localhost mysql5.7]# ./bin/mysqld_safe --defaults-file=/etc/my7.cnf --user=mysql &
[1] 5566
[root@localhost mysql5.7]# 2017-12-14T14:29:10.302174Z mysqld_safe Logging to '/data/mysql5.7/localhost.localdomain.err'.
2017-12-14T14:29:10.305015Z mysqld_safe Logging to '/data/mysql5.7/localhost.localdomain.err'.
2017-12-14T14:29:10.341094Z mysqld_safe Starting mysqld daemon with databases from /data/mysql5.7
  • 验证
[root@localhost mysql5.7]# ps aux | grep mysqld
root       5566  0.0  0.1 113268  1592 pts/0    S    22:29   0:00 /bin/sh ./bin/mysqld_safe --defaults-file=/etc/my7.cnf --user=mysql
mysql      5685  5.6 12.8 1119056 183688 pts/0  Sl   22:29   0:00 ./bin/mysqld --defaults-file=/etc/my7.cnf --basedir=/usr/local/mysql5.7 --datadir=/data/mysql5.7 --plugin-dir=/usr/local/mysql5.7/lib/plugin --user=mysql --log-error=/data/mysql5.7/localhost.localdomain.err --pid-file=/data/mysql5.7/localhost.localdomain.pid
root       5715  0.0  0.0 112676   976 pts/0    S+   22:29   0:00 grep --color=auto mysqld
  • 设置mysql密码
# 使用初始密码登录,并修改密码
[root@localhost mysql5.7]# /usr/local/mysql5.7/bin/mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.17

Copyright (c) 2000, 2016, 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> set password = password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit
Bye

# 用新密码重新登录
[root@localhost mysql5.7]# /usr/local/mysql5.7/bin/mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.17 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> 

说明

  1. 如果当前系统已经运行了一个mysql,那么启动新配置的mysql5.7将回立即关闭。
[root@localhost mysql5.7]# 2017-12-14T14:27:52.822754Z mysqld_safe Logging to '/data/mysql5.7/localhost.localdomain.err'.
Logging to '/data/mysql5.7/localhost.localdomain.err'.
2017-12-14T14:27:52.929283Z mysqld_safe Starting mysqld daemon with databases from /data/mysql5.7
2017-12-14T14:27:57.359819Z mysqld_safe mysqld from pid file /data/mysql5.7/localhost.localdomain.pid ended

[1]+  完成                  ./bin/mysqld_safe --defaults-file=/etc/my7.cnf --user=mysql
  1. 不知道mysql数据库root的密码
1. 修改配置文件
vi /etc/my7.cnf
在[mysqld]下面加一行
skip-grant-tables
保存后重启mysql

2. 修改密码
[root@localhost mysql5.7]# /usr/local/mysql/bin/mysql -uroot 
mysql> use mysql;
mysql> update user set authentication_string=password('123333') where user='root';

3. 重新修改配置文件,去除第1步添加的行
4. 重启mysql服务生效

下载地址 http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

转载于:https://my.oschina.net/LuCastiel/blog/1591625

相关文章:

  • 笨办法31做出决定
  • SQL PRIMARY KEY 约束
  • 串口工具
  • python计算器
  • 怎样实现高质量发展(展望2018)
  • 阮一峰JS基础读后感
  • 图像缩放算法【转】
  • 回到网易后开源APM技术选型与实战
  • Firefox Quantum支持跨浏览器插件架构
  • 第 196 章 X Terminal
  • latex-参考文献在子文件夹
  • iOS Core Image 滤镜实践
  • 第 14 章 Network Communication
  • 从Windows迁移SQL Server到Linux
  • fastcgi协议之一:定义
  • 《Java8实战》-第四章读书笔记(引入流Stream)
  • 【笔记】你不知道的JS读书笔记——Promise
  • DOM的那些事
  • emacs初体验
  • java小心机(3)| 浅析finalize()
  • JS学习笔记——闭包
  • JWT究竟是什么呢?
  • k个最大的数及变种小结
  • mongodb--安装和初步使用教程
  • ReactNative开发常用的三方模块
  • React的组件模式
  • Vue2 SSR 的优化之旅
  • 回顾2016
  • 你不可错过的前端面试题(一)
  • 少走弯路,给Java 1~5 年程序员的建议
  • 实战|智能家居行业移动应用性能分析
  • 一个SAP顾问在美国的这些年
  • 怎样选择前端框架
  • 正则学习笔记
  • 2017年360最后一道编程题
  • 阿里云IoT边缘计算助力企业零改造实现远程运维 ...
  • 好程序员大数据教程Hadoop全分布安装(非HA)
  • ​Z时代时尚SUV新宠:起亚赛图斯值不值得年轻人买?
  • #【QT 5 调试软件后,发布相关:软件生成exe文件 + 文件打包】
  • #pragma 指令
  • (1) caustics\
  • (1/2)敏捷实践指南 Agile Practice Guide ([美] Project Management institute 著)
  • (13):Silverlight 2 数据与通信之WebRequest
  • (delphi11最新学习资料) Object Pascal 学习笔记---第8章第5节(封闭类和Final方法)
  • (Redis使用系列) Springboot 实现Redis 同数据源动态切换db 八
  • (分类)KNN算法- 参数调优
  • (附源码)springboot猪场管理系统 毕业设计 160901
  • (简单) HDU 2612 Find a way,BFS。
  • (四) 虚拟摄像头vivi体验
  • .NET Entity FrameWork 总结 ,在项目中用处个人感觉不大。适合初级用用,不涉及到与数据库通信。
  • .NET Remoting学习笔记(三)信道
  • .Net下C#针对Excel开发控件汇总(ClosedXML,EPPlus,NPOI)
  • .NET与 java通用的3DES加密解密方法
  • @Autowired多个相同类型bean装配问题
  • @FeignClient 调用另一个服务的test环境,实际上却调用了另一个环境testone的接口,这其中牵扯到k8s容器外容器内的问题,注册到eureka上的是容器外的旧版本...