0%
Linux 安装 MySQL7 版本
安装步骤
查看服务器版本
系统版本:
$ lsb_release -cr
Release: 9.12
Codename: stretch
内核版本:
$ uname -r
4.9.0-12-amd64
下载 MySQL
根据服务器版本,下载 MySQL 安装包。
下载地址:https://downloads.mysql.com/archives/community/
安装 MySQL
以下载的 mysql-server_5.7.18-1debian9_amd64.deb-bundle.tar
为例进行说明。
解压 tar:
$ gzip mysql-server_5.7.18-1debian9_amd64.deb-bundle.tar
解压 tar.gz:
$ tar -zxvf mysql-server_5.7.18-1debian9_amd64.deb-bundle.tar.gz
安装 deb 包:
$ dpkg -i *.deb
初始化 MySQL
$ /usr/sbin/mysqld --defaults-file=/home/ddb/mysql/my3306.cnf --user=ddb --initialize
启动 MySQL
$ mysqld_safe --defaults-file=/home/ddb/mysql/my3306.cnf &
查看 root 密码
查看 MySQL 数据目录下的 mysqld.log
日志文件,如下图所示红框的地方即为 root 的初始密码。
访问 root
$ mysql --defaults-file=/home/ddb/mysql/my4336.cnf -uroot -p
Enter password:
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
此时,必须修改 root 密码。
修改 root 密码
SET PASSWORD = PASSWORD('newpassword');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;
问题处理
安装 deb 异常
安装 deb 包时出现如下异常:
dpkg: dependency problems prevent configuration of mysql-community-server:
mysql-community-server depends on libaio1 (>= 0.3.93); however:
Package libaio1 is not installed.
mysql-community-server depends on libmecab2; however:
Package libmecab2 is not installed.
mysql-community-server depends on libnuma1 (>= 2.0.11); however:
Package libnuma1 is not installed.
解决方式:
$ apt-get install libaio1 libmecab2 libnuma1
初始化异常
2021-06-04T11:13:04.485999+08:00 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-06-04T11:13:04.487043+08:00 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2021-06-04T11:13:04.487070+08:00 0 [ERROR] Aborting
这是由于初始化数据目录不为空,清空数据目录下的所有文件即可。
Windows 安装 MySQL8 版本
之前本地只安装了 MySQL 5.7 的版本,现在需要再安装一个 MySQL 8 版本。并同时运行两个 MySQL 实例。
MySQL 操作 Json 数据相关使用总结
在项目中,有部分数据是以 JsonObject 和 JsonArray 的形式直接存储在 MySQL 中的。
如果想对 这部分数据进行查询 等操作,非常不便。
经查询,MySQL 5.7.8 新增了对 Json 数据的相关支持,MySQL 8.0.4 新增了 Json 表函数的功能。
通过使用 内置的 函数,可以非常方便的对以 JsonObject 和 JsonArray 的形式直接存储在 MySQL 中的字段,进行查找、排序等操作。
本文总结了 MySQL 对 Json 操作的相关用法。
tomcat 运行报错:This is very likely to create a memory leak
问题
tomcat 运行时,报如下异常:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/Jueee/.m2/repository/org/slf4j/slf4j-log4j12/1.7.21/slf4j-log4j12-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/Jueee/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.13.3/log4j-slf4j-impl-2.13.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.
SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
26-May-2021 18:44:40.531 严重 [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
26-May-2021 18:44:40.531 严重 [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/adminWeb] startup failed due to previous errors
26-May-2021 18:44:40.545 警告 [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [adminWeb] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:502)
java.util.TimerThread.mainLoop(Timer.java:526)
java.util.TimerThread.run(Timer.java:505)