- docker mysql镜像默认是latin文,中文存进去全部变成了??,在镜像启动命令的末尾加两个参数即可解决
docker run -p 3306:3306 --privileged=true -v /home/tomatowork/data/mysql/logs:/var/log/mysql -v /home/tomatowork/data/mysql/data:/var/lib/mysql -v /home/tomatowork/data/mysql:/etc/mysql/my.cnf -e MYSQL_ROOT_PASSWORD=123456 -d mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
dcoker compose yml文件内容如下:
version: '2'
services:
db:
container_name: tomato_db
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=123456
- MYSQL_DATABASE=TomatoWork
privileged: true
ports:
- "3306:3306"
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
volumes:
- /home/tomatowork/data/mysql/logs:/var/log/mysql
- java后端代码打包总是有问题,用maven打出来的包只有11kb,用idea原生工具打包,大小倒是没问题,但是无法正常启动,最后发现原因是pom里面的spring-boot-maven-plugin配置有问题,要加上repackage才行
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.ssophie.tomatowork.App</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
- java后端maven一编译,java版本就降到了1.6,也是pom的配置问题,build模块加一个plugin配置,指定java版本1.8
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
- 常用命令总结
docker ps -a 显示所有docker容器
docker stop 容器id
docker logs 容器id
docker exec -it 容器id /bin/bash 进入某容器
rm -rf * /some/dir 强制清空某路径,千万别rm -rf * /