mysql> select version(); +------------+ | version() | +------------+ | 5.7.23-log | +------------+ 1 row in set (0.00 sec) mysql> show variables like 'innodb_fast_shutdown'; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | innodb_fast_shutdown | 1 | +----------------------+-------+ 1 row in set (0.00 sec) # 确保数据都刷到硬盘上,更改成0 mysql> set global innodb_fast_shutdown=0; Query OK, 0 rows affected (0.00 sec) mysql> shutdown; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye # 退出至终端 用mysql8.0.19客户端直接启动 [root@centos ~]# /usr/local/mysql8/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql & [1] 23333 [root@centos ~]# 2020-05-20T07:07:02.337626Z mysqld_safe Logging to '/data/mysql/logs/error.log'. 2020-05-20T07:07:02.366244Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/data # 可观察下错误日志看是否报错 然后重新登录测试 [root@centos ~]# mysql -uroot -p123456 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 17 Server version: 8.0.19 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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> select version(); +-----------+ | version() | +-----------+ | 8.0.19 | +-----------+ 1 row in set (0.00 sec)
修改环境变量
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
因basedir由/usr/local/mysql变成了/usr/local/mysql8,故相关环境变量推荐修改下。可按照以下步骤来操作验证: # 修改mysql服务启动项配置 vi /etc/init.d/mysql # 修改basedir目录 basedir=/usr/local/mysql8 # 修改PATH变量 vi /etc/profile # 将PATH中的/usr/local/mysql/bin改为/usr/local/mysql8/bin # 生效验证 [root@centos ~]# source /etc/profile [root@centos ~]# which mysql /usr/local/mysql8/bin/mysql [root@centos ~]# mysql -V mysql Ver 8.0.19 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
Tips
如果没法用systemctl来控制mysql怎么办
操作流程:
1.进入/etc/systemd/system
cd /etc/systemd/system
2.创建mysql.service
vi mysql.service
3.mysql.service中添加配置信息
1 2 3 4 5 6 7 8 9 10 11 12 13
[Unit] Description=MySQL Server After=network.target