在若依框架中需要把 数据库升级,否在linux中,定时任务的表导不进去。
下载地址:
http://mirrors.sohu.com/mysql/MySQL-5.7/
#安全的停止数据库的运行
/etc/init.d/mysql.server stop
# 解压mysql tar包
tar zxf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.28-linux-glibc2.12-x86_64 /usr/local/
cd /usr/local/
# 删除原先软连接,建立新的软连接
unlink mysql
ln -s mysql-5.7.28-linux-glibc2.12-x86_64/ mysql
#此时,MySQL的应用程序版本已经升级完成
#/etc/init.d/mysqld
#/etc/profile中PATH增加的/usr/local/mysql/bin
#都不需要做任何的改变,即可将当前系统的mysql版本升级完成
#注意:此时只是应用程序升级完成,系统表仍然还是5.6的版本
cd /usr/local/mysql
chown root.mysql . -R
/etc/init.d/mysql.server start
# 执行更新系统表,输入密码为原先的密码
mysql_upgrade -p -s
#参数 -s 一定要加,表示只更新系统表,-s: upgrade-system-tables
#如果不加-s,则会把所有库的表以5.7.9的方式重建,线上千万别这样操作
#因为数据库二进制文件是兼容的,无需升级
#什么时候不需要-s ? 当一些老的版本的存储格式需要新的特性,
# 来提升性能时,不加-s
#即使通过slave进行升级,也推荐使用该方式升级,速度比较快
# 查看升级后的版本
mysql -V
# mysql Ver 14.14 Distrib 5.7.28, for linux-glibc2.12 (x86_64) using EditLine wrapper
升级完登录
[root@localhost mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cms |
| mysql |
| performance_schema |
| sys | # 5.7 新的sys库
| test |
+--------------------+
6 rows in set (0.00 sec)
mysql>
mysql 5.6 卸载
- find / -name mysql 查看mysql相关目录
- 删除项目的mysql文件
- 卸载后/etc/my.cnf不会删除,需要进行手工删除 rm -rf /etc/my.cnf
- 再次查找机器是否安装mysql rpm -qa|grep -i mysql
mysql5.7安装
- 解压
[root@VM-0-6-centos packes]# tar -xzvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -C /www/server/mysql5-7
- 重属名
[root@VM-0-6-centos mysql5-7]# mv mysql-5.7.28-linux-glibc2.12-x86_64 mysql-5.7.28
- 新建配置文件/mysql-5.7.28/support-files目录下创建my_default.cnf
- 设置环境变量和开机启动
- 环境变量 vim /etc/profile
#set java mysql environment
export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64
export MYSQL_HOME=/www/server/mysql5-7/mysql-5.7.28
export PATH=$PATH:$JAVA_HOME/bin:$MYSQL_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
刷新系统环境配置:source /etc/profile
- 开机启动
chkconfig --add mysql mysql服务到自启服务
chkconfig mysql on 设置自启
chkconfig --list查看服务列表
- 登录 mysql-u root -p
centos 安装5.7
二进制rpm
二进制 预编译
源码包安装
- 安装环境
[root@VM-0-6-centos /]# rpm -q mariadb-server
package mariadb-server is not installed
rpm -qa|grep mysql 把有关mysql删除掉
rpm -e mysql80-community-release-el7-3.noarch
- yum 安装
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
rpm 安装mysql仓库
[root@VM-0-6-centos /]# rpm -ivh mysql57-community-release-el7-11.noarch.rpm
warning: mysql80-community-release-el7-3.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql80-community-release-el7-3 ################################# [100%]
- 查看 yum仓库
[root@VM-0-6-centos /]# ls /etc/yum.repos.d/
- 更新仓库
[root@VM-0-6-centos /]# yum makecache
- yum repolist
[root@VM-0-6-centos /]# yum list|grep mysql-com
安装
-
rpm -qa|grep mysql ;如果有 删除 rpm -e mysql57-community-release
rpm -qa|grep mariadb; 如果有 删除 rpm -e --nodeps mysql-community-client-5.7.25-1.el6.x86_64
find / -name mysql ; 如果有 删除 rm -rf /www/backup/oldData/mysql
chmod -R 777 *; 文件授权
[root@VM-0-6-centos mysql-5.7.25-1.el6.x86_64.rpm-bundle]# ll
total 464764
-rwxrwxrwx 1 root root 23853144 Apr 8 17:02 mysql-community-client-5.7.25-1.el6.x86_64.rpm
-rwxrwxrwx 1 root root 340184 Apr 8 17:02 mysql-community-common-5.7.25-1.el6.x86_64.rpm
-rwxrwxrwx 1 root root 3797584 Apr 8 17:02 mysql-community-devel-5.7.25-1.el6.x86_64.rpm
-rwxrwxrwx 1 root root 39489784 Apr 8 17:02 mysql-community-embedded-5.7.25-1.el6.x86_64.rpm
-rwxrwxrwx 1 root root 137670944 Apr 8 17:03 mysql-community-embedded-devel-5.7.25-1.el6.x86_64.rpm
-rwxrwxrwx 1 root root 2203408 Apr 8 17:02 mysql-community-libs-5.7.25-1.el6.x86_64.rpm
-rwxrwxrwx 1 root root 1723740 Apr 8 17:02 mysql-community-libs-compat-5.7.25-1.el6.x86_64.rpm
-rwxrwxrwx 1 root root 160646088 Apr 8 17:03 mysql-community-server-5.7.25-1.el6.x86_64.rpm
-rwxrwxrwx 1 root root 106159460 Apr 8 17:03 mysql-community-test-5.7.25-1.el6.x86_64.rpm
- rpm -ivh mysql-community-common-5.7.25-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.25-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.25-1.el6.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-devel-5.7.25-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.25-1.el6.x86_64.rpm
[root@VM-0-6-centos mysql]# ll
total 530376
-rw-r--r-- 1 7155 31415 26468960 Dec 11 13:20 mysql-community-client-5.7.33-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 315280 Dec 11 13:20 mysql-community-common-5.7.33-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 3918736 Dec 11 13:20 mysql-community-devel-5.7.33-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 47513604 Dec 11 13:20 mysql-community-embedded-5.7.33-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 23261952 Dec 11 13:20 mysql-community-embedded-compat-5.7.33-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 131045776 Dec 11 13:21 mysql-community-embedded-devel-5.7.33-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 2458780 Dec 11 13:21 mysql-community-libs-5.7.33-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 1260364 Dec 11 13:21 mysql-community-libs-compat-5.7.33-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 181817592 Dec 11 13:21 mysql-community-server-5.7.33-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 125021984 Dec 11 13:21 mysql-community-test-5.7.33-1.el7.x86_64.rpm
[root@VM-0-6-centos mysql]# rpm -ivh mysql-community-common-5.7.33-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.33-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.33-1.e################################# [100%]
[root@VM-0-6-centos mysql]# rpm -ivh mysql-community-libs-5.7.33-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.33-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.33-1.el7################################# [100%]
[root@VM-0-6-centos mysql]# rpm -ivh mysql-community-client-5.7.33-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.33-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libncurses.so.5()(64bit) is needed by mysql-community-client-5.7.33-1.el7.x86_64
libtinfo.so.5()(64bit) is needed by mysql-community-client-5.7.33-1.el7.x86_64
[root@VM-0-6-centos mysql]# rpm -ivh mysql-community-client-5.7.33-1.el7.x86_64.rpm --force --nodeps
warning: mysql-community-client-5.7.33-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.33-1.e################################# [100%]
[root@VM-0-6-centos mysql]# rpm -ivh mysql-community-server-5.7.33-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.33-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.33-1.el7.x86_64
libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-5.7.33-1.el7.x86_64
libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-5.7.33-1.el7.x86_64
[root@VM-0-6-centos mysql]# rpm -ivh mysql-community-server-5.7.33-1.el7.x86_64.rpm --force --nodeps
warning: mysql-community-server-5.7.33-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.33-1.e################################# [100%]
[/usr/lib/tmpfiles.d/libstoragemgmt.conf:1] Line references path below legacy directory /var/run/, updating /var/run/lsm → /run/lsm; please update the tmpfiles.d/
drop-in file accordingly.[/usr/lib/tmpfiles.d/libstoragemgmt.conf:2] Line references path below legacy directory /var/run/, updating /var/run/lsm/ipc → /run/lsm/ipc; please update the tmp
files.d/ drop-in file accordingly.[/usr/lib/tmpfiles.d/mysql.conf:23] Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ d
rop-in file accordingly.
- service mysqld start
[root@VM-0-6-centos mysql]# systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xe" for details.
解决:
https://blog.csdn.net/ypp91zr/article/details/81868195;
https://blog.csdn.net/qq_21138747/article/details/108006958
查看东西:
[root@VM-0-6-centos mysql]# systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: activating (start-pre) since Thu 2021-04-08 18:35:23 CST; 2s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 2213292 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=127)
Cntrl PID: 2213295 (mysqld_pre_syst)
Tasks: 2 (limit: 5089)
Memory: 43.3M
CGroup: /system.slice/mysqld.service
├─2213295 /bin/bash /usr/bin/mysqld_pre_systemd
└─2213322 /usr/libexec/platform-python -Es /usr/sbin/semanage fcontext -a -e /var/lib/mysql /var/lib/mysql-keyring
Apr 08 18:35:23 VM-0-6-centos systemd[1]: mysqld.service: Service RestartSec=100ms expired, scheduling restart.
Apr 08 18:35:23 VM-0-6-centos systemd[1]: mysqld.service: Scheduled restart job, restart counter is at 16.
Apr 08 18:35:23 VM-0-6-centos systemd[1]: Stopped MySQL Server.
Apr 08 18:35:23 VM-0-6-centos systemd[1]: Starting MySQL Server...
- grep 'temporary password' /var/log/mysqld.log
yum clean all
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US