mysql5.6升级

mysql5.6的升级可以分为以下几个步骤:

  • 安全关闭正在运行的MySQL实例
  • 把/usr/local/mysql 的连接由MySQL5.6更改为MySQL5.7
  • 启动MySQL实例,查看是否是MySQL5.7版本
  • 使用mysql_upgrade命令升级系统表

首先:停止当前运行的MySQL实例,然后做如下操作

更改之后启动MySQL实例:

[root@test3 local]# service mysqld start
Starting MySQL.. SUCCESS!
[root@test3 local]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0.0.0.0: 0.0.0.0:* LISTEN /sshd
tcp ::: :::* LISTEN /sshd
tcp ::: :::* LISTEN /grafana-serve
tcp :::

然后连接MySQL,可以看到MySQL已经有原来的5.6版本升级为5.7版本:

[root@test3 ~]# mysql -S /tmp/mysql.sock -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-log MySQL Community Server (GPL) Copyright (c) , , Oracle, SkySQL Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> exit
Bye
[root@test3 ~]#

这时候利用mysql_upgrade命令升级用户表

[root@test3 ~]# mysql_upgrade -s -p
Enter password:
The --upgrade-system-tables option was used, databases won't be touched.
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Upgrading the sys schema.
Upgrade process completed successfully.
Checking if update is needed. #需要注意的是这个命令在执行过程中会重构数据库中所有的表,但是升级的时候,用户的数据表,是不需要重构的,因此我们使用看-s参数,表示只是重构系统表。

如果这一步的操作没有报错,那就说明MySQL实例升级完毕!

mysql的无密码登录

第一种:我们可以把用户名和密码写进配置文件中,来实现无密码登录。

查看一下mysql默认读取配置文件的路径:

[root@test3 mysql]# mysql --help |grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
[root@test3 mysql]#

我们可以在当前用户的家目录下面创建用户名和密码,如下:

[root@test2 ~]# cat .my.cnf
[client]
user=root
password=
[root@test2 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.6.-log Source distribution Copyright (c) , , 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自带的mysql_condif_editory命令的设置无密码登录。

[root@test2 ~]# mysql_config_editor --help
mysql_config_editor Ver 1.0 Distrib 5.6., for Linux on x86_64
Copyright (c) , , 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. MySQL Configuration Utility.
Usage: mysql_config_editor [program options] [command [command options]]
-?, --help Display this help and exit.
-v, --verbose Write more information.
-V, --version Output version information and exit. Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- ----------------------------------------
verbose FALSE Where command can be any one of the following :
set [command options] Sets user name/password/host name/socket/port
for a given login path (section).
remove [command options] Remove a login path from the login file.
print [command options] Print all the options for a specified
login path.
reset [command options] Deletes the contents of the login file.
help Display this usage/help information.

mysql_config_editor命令

实例:

[root@test2 ~]# mysql_config_editor set --user=root --host=localhost --password
Enter password:
[root@test2 ~]# ls .mylogin.cnf
.mylogin.cnf
[root@test2 ~]# #这里的密码必须在交互输入,然后就可以直接无密码登录
[root@test2 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.6.-log Source distribution Copyright (c) , , 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>

生成的文件是一个二进制文件,可以使用print参数查看

[root@test2 ~]# mysql_config_editor print --all
[client]
user = root
password = *****
host = localhost
[root@test2 ~]#

此命令还可以使用使用--login-path命令,如下:

[root@test2 ~]# mysql_config_editor set --login-path=test --user=root --host=localhost --password
Enter password:
[root@test2 ~]# mysql_config_editor print --login-path=test
[test]
user = root
password = *****
host = localhost
[root@test2 ~]# mysql --login-path=test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.6.-log Source distribution Copyright (c) , , 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>

--login-path也是在当前家目录下面生成.mylogin.cnf文件,这个文件以 [ ] 进行标识!

mysql5.6升级及mysql无密码登录的更多相关文章

  1. mysql无密码登陆

    mysql登陆不上或者密码忘记可以尝试一下无密码登陆 以下一波神操作!! 首先关闭数据库服务(数据库在Centos7版本以上或者Redhat版本上被改名为mariadb) systemctl stop ...

  2. MySQL5.1升级5.6后,执行grant出错:ERROR 2013 (HY000): Lost connection to MySQL server during query【转载】

    转载: MySQL5.5升级5.6后,执行grant出错:ERROR 2013 (HY000): Lost connection to -mysql教程-数据库-壹聚教程网http://www.111 ...

  3. MySQL 5.1.73升级为MySQL 5.5.35详解

    一.前言 二.概述 三.安装MySQL 5.1.73 四.升级为MySQL 5.5.35 五.总结 注,测试环境 CentOS 6.4 x86_64,MySQL 版本(5.1.73.5.5.35)目前 ...

  4. Mac安装Mysql无法登录

    Mac安装的Mysql5.7.10 执行mysql -u root -p 就要求输入密码,但是新安装是没密码的.然后就会报错. ERROR 1045 (28000): Access denied fo ...

  5. linux下MySQL安装登录及操作

    linux下MySQL安装登录及操作 二.安装Mysql 1.下载MySQL的安装文件 安装MySQL需要下面两个文件: MySQL-server-4.0.16-0.i386.rpm MySQL-cl ...

  6. 对于mariadb安装后可以默认使用无密码登录的问题解决方案

    mariadb安装后默认可以无密码登录 所以首先我们要设置root用户的密码 mysqladmin -u root -p password 密码 [遇到enter直接enter就行,注意,如果是重新设 ...

  7. P1-Linux下安装MySQL及登录用户配置

    Linux下安装MySQL及登录用户配置 环境:Centos7.4    Mysql5.6 1. 查询是否安装 MySQL和MariaDB rpm -qa | grep -i mysql rpm -q ...

  8. 开启mysql远程登录

    开发过程中经常遇到远程访问mysql的问题,每次都需要搜索,感觉太麻烦,这里记录下,也方便我以后查阅. 首先访问本机的mysql(用ssh登录终端,输入如下命令): mysql -uroot -p 输 ...

  9. 如何在忘记mysql的登录密码时更改mysql登录的密码(window及linux)

    最近一直在边学习边开发java项目,理所当然的就少不了跟数据库打交道了,但是有时候就会脑子一短路,把mysql的登录密码给忘记了,这个时候我们又很急切的需要进到数据库中查看数据,那这个时候要怎么才能改 ...

随机推荐

  1. JavaEE Cookie HttpSession 学习笔记

    1. 会话管理概述 1.1 什么是会话 好比一次通话.打开浏览器,点击多次链接(发出多次请求和收到多次的响应),关闭浏览器,这个过程就是一次会话. 有功能 可以  文件 新建会话 1.2 解决的问题是 ...

  2. Python面向对象之方法

    普通方法要执行类里面的方法是通过对象触发的 触发的时候把自己赋值给self 类方法 vim day7-7.py #!/usr/bin/python # -*- coding:utf-8 -*- cla ...

  3. POJ-2336 Ferry Loading II(简单DP)

    Ferry Loading II Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3763 Accepted: 1919 Desc ...

  4. HDFS体系结构(NameNode、DataNode详解)

    hadoop项目地址:http://hadoop.apache.org/ NameNode.DataNode详解 (一)分布式文件系统概述 数据量越来越多,在一个操作系统管辖的范围存不下了,那么就分配 ...

  5. linux:用户及文件权限管理

    学习内容来自实验楼.莫烦python.CSDN 一.Linux 用户管理 1. 查看用户 who am i 或者who mom likes who -a:打印所有能打印的  who -d :打印死掉的 ...

  6. 使用Maven导出项目依赖的jar包

    步骤1.进入项目目录(有pom.xml的目录) 2.创建存放导出jar依赖包的目录 3.地址栏输入cmd,回车 4.输入导出命令,回车mvn dependency:copy-dependencies  ...

  7. PL/SQL常用语法及举例

    PLSQL语句 DECLARE 声明部分 BEGIN 程序编写,SQL语句 EXECPTION 处理异常 END; / 声明部分(DECLARE) SQL> set serveroutput o ...

  8. windows7系统下让所有文件夹都使用同一种视图的方法

    Windows7系统可以对每个文件夹进行个性化视图设置,可以根据自己的个人喜好和实际需要更改文件或文件夹图标的大小,或者让文件或文件夹以列 表.平铺等方式显示.但是,如果你对N个文件夹视图进行了风格各 ...

  9. MySQL中死锁

    1 .死锁的概念 是指两个或两个以上的事务在执行过程中,因争夺资源而造成的一种互相等待的现象.若无外力作用,事务都将无法推进下去,解决死锁的最简单问题是不要有等待,任何的等待都转换为回滚,并且事务重新 ...

  10. mysql 操作sql语句 操作数据表

    #2. 操作文件 先切换到文件夹下:use db1 查看当前所在的数据库 mysql> select database(); +------------+ | database() | +--- ...