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. Python 重定向获取真实url

    通常的返回url: http_headers = { 'Accept': '*/*','Connection': 'keep-alive', 'User-Agent': 'Mozilla/5.0 (W ...

  2. org.springframework.dao.InvalidDataAccessApiUsageException

    org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read ...

  3. hdu4027Can you answer these queries?【线段树】

    A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use ...

  4. CSU 1808 - 地铁 - [最短路变形]

    题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1808 Time limit: 5000 ms Memory limit: 13107 ...

  5. python 将字符串转换为字典

    在一般的工程处理中,需要将获取的字符串数据转换为字典,这样处理起来会非常方便. 我获取的是json数据: content = {"corpus_no":"64702772 ...

  6. 初次安装hive-2.1.0启动报错问题解决方法

    首次安装hive-2.1.0,通过bin/hive登录hive shell命令行,报错如下: [hadoop@db03 hive-2.1.0]$ bin/hive which: no hbase in ...

  7. 第一个socket服务端程序

    第一个socket服务端程序 #include <stdio.h> #include <stdlib.h> #include <string.h> #include ...

  8. JSON.stringify() 格式化 输出log

    调试程序的过程中,我们打印一个日志: console.log(object);,其中object是任意的一个json对象. 在控制台就会看到[object object],而看不到具体的内容. 我们可 ...

  9. javaweb使用 window.location.href 传中文参数 乱码问题

    JS: var cn_name=  document.getElementById("cn_name"); window.location.href="${URL}?na ...

  10. 洛谷P1941 飞扬的小鸟 [noip2014] 背包

    正解:背包 解题报告: 话说好久没做背包的题了,都有些陌生了?这几天加强基础题目多刷点儿dp和背包趴qwq 其实这题是95...然后我下了我错的那个测试点,我答案是9874正解是9875...然后读入 ...