mysql8.0好处,MySQL8.0带来的两点便利

这两天在做MySQL5.7~MySQL8.0的版本升级,收集整理了MySQL8.0的几个比较便利的地方,分享出来,大家可以参考一下。01服务重启

mysql服务重启在不同的版本中有不同的方法,这里针对mysql5.5、mysql5.7、mysql8.0做一下简单分析。

在MySQL5.5版本中,如果我们想要重启MySQL数据库,我们需要使用mysqladmin这个工具,或者使用service mysqld stop命令来停止MySQL服务,其中mysqladmin的工具示例如下:mysqladmin -uroot -pyeyz -h127.0.0.1  shutdown

停止数据库之后,需要使用mysqld或者mysqld_safe工具重新启动数据库。

在MySQL5.7版本中,如果我们想重启服务,相对就比较容易了,不需要使用mysqladmin工具来进行服务停止,而是直接通过mysql交互式命令行里面的shutdown命令,就可以完成数据库的停止,如果你想重启,那不好意思,需要使用mysqld或者mysqld_safe工具来进行启动。

在MySQL8.0中,服务重启就没有那么麻烦了,如果你是使用mysqld_safe启动的mysql服务,则直接使用restart命令来重启服务就可以了。相对比较方便。如下:mysql> \s

--------------

/usr/local/Percona-Server-8.0.19-10-Linux.x86_64.ssl101/bin/mysql  Ver 8.0.19-10 for Linux on x86_64 (Percona Server (GPL), Release 10, Revision f446c04)

------

Uptime:                 7 days 17 min 39 sec

Threads: 2  Questions: 20  Slow queries: 0  Opens: 133  Flush tables: 3  Open tables: 53  Queries per second avg: 0.000

--------------

mysql> restart;

Query OK, 0 rows affected (0.00 sec)

mysql> select 1;

ERROR 2006 (HY000): MySQL server has gone away

No connection. Trying to reconnect...

Connection id:    8

Current database: *** NONE ***

+---+

| 1 |

+---+

| 1 |

+---+

1 row in set (0.00 sec)

mysql> \s

--------------

/usr/local/Percona-Server-8.0.19-10-Linux.x86_64.ssl101/bin/mysql  Ver 8.0.19-10 for Linux on x86_64 (Percona Server (GPL), Release 10, Revision f446c04)

--------------

UNIX socket:            /data/mysql_4306/tmp/mysql.sock

Binary data as:         Hexadecimal

Uptime:                 8 sec

Threads: 2  Questions: 6  Slow queries: 0  Opens: 115  Flush tables: 3  Open tables: 35  Queries per second avg: 0.750

--------------

从启动前后\s命令输出中的uptime可以看到,当前数据库已经被重启过一次了。02额外端口admin_port

额外端口admin_port的存在,为我们在某些特殊场景下登录MySQL提供了可能。例如在出现too many connections这个报错的时候,可以使用额外端口进行登录。额外端口在my.cnf文件中的配置如下:[root@VM-0-14-centos ~]# cat /data/mysql_4306/my.cnf | grep admin

create_admin_listener_thread=1

admin_port=43061

admin_address=127.0.0.1

下面是分别使用端口4306和额外端口43061登录的日志:[root@VM-0-14-centos ~]# mysql -uroot -pyeyazhou -P43061 --socket=/data/mysql_4306/tmp/mysql.sock

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

······

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit

Bye

[root@VM-0-14-centos ~]# mysql -uroot -pyeyazhou -P4306 --socket=/data/mysql_4306/tmp/mysql.sock

mysql: [Warning] Using a password on the command line interface can be insecure.

......

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> exit

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值