补充Mysql5.7用法
下面简单介绍一下安装:
[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用法的更多相关文章
- 今天给大家补充一下 background 用法
补充一个知识点 1,浏览器默认字体大小是font-size:16px:谷歌最小字体是10px,其他浏览器是12px 2. 选择器 通配符选择器 * 表示 3.background 背景 ...
- Python学习笔记(补充)Split 用法
>>> u = "www.doiido.com.cn" #使用默认分隔符 >>> print u.split() ['www.doiido.co ...
- 通过Oracle补充日志,找到锁阻塞源头的SQL
问题背景: 有时会考虑一件事情,如果在Oracle环境下出现了锁阻塞的情况,如何定位到SQL源头(通过session.lock.transaction等视图仅能定位到会话)?或许有人会想有没有可能通过 ...
- atomic 原子自增工程用法案例
案例 1 : 简单用法 atomic_int id; atomic_fetch_add(&id, 1) atomic_uint id; atomic_fetch_add(&id, 1) ...
- R语言实战(二)数据管理
本文对应<R语言实战>第4章:基本数据管理:第5章:高级数据管理 创建新变量 #建议采用transform()函数 mydata <- transform(mydata, sumx ...
- <老友记>学习笔记
这是六个人的故事,从不服输而又有强烈控制欲的monica,未经世事的千金大小姐rachel,正直又专情的ross,幽默风趣的chandle,古怪迷人的phoebe,花心天真的joey——六个好友之间的 ...
- vi/vim使用指北 ---- Moving Around in a Hurry
上一篇文章中,简单列出了一些基本的Vim操作,也列出了很多的光标移动命令,本章主要是有哪些命令可以更快的移动光标. vim的编辑操作,用得最多就是移动光标,对于很少行的文件来说,基本的命令就够用了,但 ...
- linux反弹shell
参考链接 http://www.cnblogs.com/r00tgrok/p/reverse_shell_cheatsheet.html http://www.waitalone.cn/linux-s ...
- C#中内嵌资源的读取
起因 作为一个从Cpper转到C#并且直接从事WPF开发的萌新来说,正式编码过程中碰到了不少问题,一路上磕磕碰碰的.因为软件设计需求上的要求,需要将一些配置文件(XML.INI等)内嵌到程序中,等需要 ...
随机推荐
- 05_Linux目录文件操作命令2_我的Linux之路
这一节我们继续来学习Linux中对文件和目录的操作命令 mkdir 创建目录 mkdir (选项)(参数) 在Linux端可以使用mkdir来创建目录,如果你没有加其他的路径名,那么默认是在当前目录下 ...
- SQL执行计划分析
explain执行计划中的字段以及含义在下面的博客中有详细讲述: https://blog.csdn.net/da_guo_li/article/details/79008016 执行计划能告诉我们什 ...
- EasyUI 冻结列
一.如果是js绘制的,设置frozenColumn属性就可以,frozenColumn 属性和 columns 属性都是设置列,frozenColumn是设置冻结列 $('#tt').datagrid ...
- Python基础-用户验证
一.项目需求 1.根据用户名和密码,验证用户是否可登陆 2.允许一次执行可验证三次 3.当用户名输错三次后,该用户名锁定,永久不可登陆 二.代码如下 #!/usr/bin/env python #-* ...
- Struts(十二):异常处理:exception-mapping元素
配置当前action的声明异常处理 1.exception-mapping元素中有2个属性 exception:指定需要捕获的异常类型 result:指定一个响应结果,该结果将在捕获到异常时被执行.即 ...
- AFNetworking 源码解读
最近开始看第三方库优秀源码的计划,这是第一个,AFNetworking来和大家分享一下. AFNetworking 是一个十分优秀的网络框架,简单易用. 在开始之前,最好先了解一下NSURLSessi ...
- Python处理Excel生成CSV文档
Python是一种解释型的.动态数据类型的.面向对象的高级程序设计语言.拥有丰富的处理数据和文本类库,并且得益于它是一种解释型的语言,在程序修改和功能扩展上,可以很容易做到大规模的调整.综合考虑Pyt ...
- [LeetCode] Teemo Attacking 提莫攻击
In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned ...
- mv&cp
mv [选项] [源] [目标] 当目标不存在时,重命名源为目标 当目标存在时,若目标为目录文件,将源移动到目标文件里: 若目标为非目录文件,将源重命名为目标,并强制覆盖目标. mv -b 1 2 ...
- wows
[问题描述]山山最近在玩一款游戏叫战舰世界(steam 游戏太少了),他被大舰巨炮的魅力折服,于是山山开了一局游戏,这次发现目标是一艘战列舰新墨西哥级,舰桥很高,原本应该打在目标身后的圆形水域内的炮弹 ...