下面简单介绍一下安装:

[root@MySQL soft]# tar xf mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz -C /data/service/
[root@MySQL soft]# cd /data/service/
[root@MySQL service]# mv mysql-5.7.10-linux-glibc2.5-x86_64/ mysql-5.7.10

下面进行数据目录的创建以及授权:

[root@MySQL service]#  mkdir /data/{mysql3306,mysql3306log} -p
[root@MySQL service]# groupadd mysql
[root@MySQL service]# useradd -r -g mysql mysql
[root@MySQL service]# chown -R mysql:mysql mysql-5.7.10/
[root@MySQL service]# chown -R mysql:mysql /data/mysql3306*

基本操作已经完成,下面进行初始化操作,在MySQL 5.7的初始化操作与MySQL 5.6有点不同了,下面在MySQL 5.7的版本用MySQL 5.6的初始化方式进行操作一下,让大家看下会报什么错:

[root@MySQL mysql-5.7.10]# ./bin/mysql_install_db --user=mysql --datadir=/data/mysql3306
2016-01-21 11:29:05 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-01-21 11:29:10 [ERROR] The bootstrap log isn't empty:
2016-01-21 11:29:10 [ERROR] 2016-01-21T03:29:05.633658Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2016-01-21T03:29:05.641584Z 0 [ERROR] Can't read from messagefile '/usr/share/mysql/english/errmsg.sys'
[root@MySQL mysql-5.7.10]#

可以看到mysql_install_db is deprecated,说不赞同使用mysql_install_db,推荐使用的方法是:

Please consider switching to mysqld --initialize ,Please consider using --initialize instead

正确的初始方式如下:./bin/mysqld --initialize --user=mysql --basedir=/data/service/mysql-5.7.10/  --datadir=/data/mysql3306,如果datadir目录有文件,则会报以下错:

[root@MySQL mysql-5.7.10]# ./bin/mysqld --initialize --user=mysql --basedir=/data/service/mysql-5.7.10/  --datadir=/data/mysql3306
2016-01-21T05:43:56.355999Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-21T05:43:56.357796Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2016-01-21T05:43:56.357814Z 0 [ERROR] Aborting

所以要把data directory文件删除掉再执行,如果删除目录下的文件还是报同样的错,可以试试把目录删除掉,再创建一个,然后授权:

[root@MySQL mysql-5.7.10]# ./bin/mysqld --initialize --user=mysql --basedir=/data/service/mysql-5.7.10/  --datadir=/data/mysql3306
2016-01-21T05:47:01.804937Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-21T05:47:03.552899Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-01-21T05:47:03.816849Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-01-21T05:47:03.883956Z 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: 660686ae-c002-11e5-843e-00163e0217d7.
2016-01-21T05:47:03.886131Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-01-21T05:47:03.887120Z 1 [Note] A temporary password is generated for root@localhost: )vyd3aXj8hhC

MySQL 5.7初始化完后会生成一个临时的密码,A temporary password is generated for root@localhost: )vyd3aXj8hhC 如果想初始化表空间,在后面加上 --innodb_data_file_path=ibdata1:1G:autoextend即可。

启动MySQL 5.7,拷贝support-files/my-default.cnf ./

[root@MySQL mysql-5.7.10]# cp support-files/my-default.cnf ./my.cnf
[root@MySQL mysql-5.7.10]# chown -R mysql:mysql my.cnf

编辑my.cnf加上基本选项:

[mysqld]
# changes to the binary log between backups.
log_bin # These are commonly set, remove the # and set as required.
basedir = /data/service/mysql-5.7.10
datadir = /data/mysql3306
port = 3306
server_id = 100
socket = /tmp/mysqld.sock

编辑启动脚本:

[root@MySQL mysql-5.7.10]# cat start_mysql.sh
#!/bin/bash nohup /data/service/mysql-5.7.10/bin/mysqld_safe --defaults-file=/data/service/mysql-5.7.10/my.cnf > /data/service/mysql-5.7.10/start_stop.log 2>&1 &

运行脚本启动 sh start_mysql.sh 。

登录MySQL 5.7,先添加MySQL 5.7的bin路径:

[root@MySQL mysql-5.7.10]# cat /etc/profile.d/mysql.sh
export PATH=/data/service/mysql-5.7.10/bin:$PATH
[root@MySQL mysql-5.7.10]# source /etc/profile.d/mysql.sh

登录时输入的密码是刚刚初始化完的密码:

[root@MySQL mysql-5.7.10]# mysql -uroot -p')vyd3aXj8hhC' -S /tmp/mysqld.sock
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 2
Server version: 5.7.10-log Copyright (c) 2000, 2015, 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>

第一次登录,是必须要修改密码才能查看show databases;

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>

从上面的信息可以看到,叫我们使用ALTER USER进行修改,下面我们修改一下密码,有关更多MySQL 5.7的用户密码设置可以参考:https://dev.mysql.com/doc/refman/5.7/en/password-expiration-policy.html

mysql> ALTER USER USER() IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.01 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec) mysql>

补充Mysql5.7用法的更多相关文章

  1. 今天给大家补充一下 background 用法

    补充一个知识点 1,浏览器默认字体大小是font-size:16px:谷歌最小字体是10px,其他浏览器是12px 2. 选择器 通配符选择器     *   表示 3.background  背景 ...

  2. Python学习笔记(补充)Split 用法

    >>> u = "www.doiido.com.cn" #使用默认分隔符 >>> print u.split() ['www.doiido.co ...

  3. 通过Oracle补充日志,找到锁阻塞源头的SQL

    问题背景: 有时会考虑一件事情,如果在Oracle环境下出现了锁阻塞的情况,如何定位到SQL源头(通过session.lock.transaction等视图仅能定位到会话)?或许有人会想有没有可能通过 ...

  4. atomic 原子自增工程用法案例

    案例 1 : 简单用法 atomic_int id; atomic_fetch_add(&id, 1) atomic_uint id; atomic_fetch_add(&id, 1) ...

  5. R语言实战(二)数据管理

    本文对应<R语言实战>第4章:基本数据管理:第5章:高级数据管理 创建新变量 #建议采用transform()函数 mydata <- transform(mydata, sumx ...

  6. <老友记>学习笔记

    这是六个人的故事,从不服输而又有强烈控制欲的monica,未经世事的千金大小姐rachel,正直又专情的ross,幽默风趣的chandle,古怪迷人的phoebe,花心天真的joey——六个好友之间的 ...

  7. vi/vim使用指北 ---- Moving Around in a Hurry

    上一篇文章中,简单列出了一些基本的Vim操作,也列出了很多的光标移动命令,本章主要是有哪些命令可以更快的移动光标. vim的编辑操作,用得最多就是移动光标,对于很少行的文件来说,基本的命令就够用了,但 ...

  8. linux反弹shell

    参考链接 http://www.cnblogs.com/r00tgrok/p/reverse_shell_cheatsheet.html http://www.waitalone.cn/linux-s ...

  9. C#中内嵌资源的读取

    起因 作为一个从Cpper转到C#并且直接从事WPF开发的萌新来说,正式编码过程中碰到了不少问题,一路上磕磕碰碰的.因为软件设计需求上的要求,需要将一些配置文件(XML.INI等)内嵌到程序中,等需要 ...

随机推荐

  1. RESTful API 编写指南

    基于一些不错的RESTful开发组件,可以快速的开发出不错的RESTful API,但如果不了解开发规范的.健壮的RESTful API的基本面,即便优秀的RESTful开发组件摆在面前,也无法很好的 ...

  2. istio入门(01)istio是什么?

  3. ICC_lab总结——ICC_lab5:布线&&数字集成电路物理设计学习总结——布线

    字丑,禁止转载! 这里将理论总结和实践放在一起了. 布线的理论总结如下所示: 下面是使用ICC进行实践的流程: 本次的布线实验主要达成的目标是: ·对具有时钟树布局后的设计进行可布线性检查 ·完成布线 ...

  4. centos系统php5.6版本安装gd扩展库

    由于项目需要显示验证码登录系统,所以这里需要开启php的gd扩展 这边提供安装php5.6的yum方法扩展自选.# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fe ...

  5. Python第三方库的安装方法总结

    源码安装 很多第三方库都是开源的,几乎都可以在github 或者 pypi上找到源码.找到源码格式大概都是 zip . tar.zip. tar.bz2格式的压缩包.解压这些包,进入解压好的文件夹,通 ...

  6. AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle

    https://beta.atcoder.jp/contests/abc075/tasks/abc075_d 题意: 给出坐标平面上n个点的坐标,要求找到一个面积最小的矩形使得这个矩形的边界加上内部的 ...

  7. Struts(十七):通过CURD来学习paramsPrepareParams拦截器栈

    背景: 通过上一章节<Struts(十六):通过CURD来学习Struts流程及ModelDriven的用法>学习了ModelDriven拦截器的用法,上章节中讲到了edit功能. 要修改 ...

  8. 单源最短路径---Bellman-Ford算法

    传送门: Dijkstra Bellman-Ford SPFA Floyd 1.Dijkstra算法的局限性 像上图,如果用dijkstra算法的话就会出错,因为如果从1开始,第一步dist[2] = ...

  9. [Linux]使用awk批量杀进程的命令

    碰到需要杀掉某一类进程的时候,如何批量杀掉这些进程,使用awk命令是很好的选择. ps -ef|grep aaa|grep -v grep|awk '{print "kill -9 &quo ...

  10. Javascript中的url编码与解码(详解)

    摘要 本文主要针对URI编解码的相关问题做了介绍,对url编码中哪些字符需要编码.为什么需要编码做了详细的说明,并对比分析了Javascript中和编解码相关的几对函数escape / unescap ...