在windows系统,使用docker,基于ubuntu18.04镜像,配置mysql,运行jar,打包导出镜像,导入镜像启动服务

解决了下面的问题

  • 数据库不是utf8
  • Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
  • Access Denied for user root @localhost

下面是全部命令行

docker run --name bestic-bfa -p 8734:8734 -it ubuntu:18.04 /bin/bash

docker cp C:\Users\bfa\Desktop\Clipboard\bfa-0.0.1-SNAPSHOT-8734-3306-bestic.jar bestic-bfa:/bfa-0.0.1-SNAPSHOT-8734-3306-bestic.jar

docker cp D:\bfa\毕设2022\初始化\bestic-file bestic-bfa:/

docker cp D:\bfa\毕设2022\初始化\bestic-init bestic-bfa:/

apt-get update

apt-get upgrade

apt-get install default-jre -y

apt-get install vim -y

apt-get install mysql-server -y

mkdir -p /var/run/mysqld

chown mysql /var/run/mysqld/

vim /etc/mysql/mysql.conf.d/mysqld.cnf


[client]
default-character-set=utf8

[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci


mysql


use mysql;
update user set authentication_string=PASSWORD("BlueFlameAshe") where user='root';
update user set plugin="mysql_native_password";
flush privileges;
quit;


service mysql restart

mysql -u root -p
BlueFlameAshe



create database bestic;
use bestic;
source /bestic-init/z0_bestic.sql;
source /bestic-init/z1_init.sql;
source /bestic-init/z2_test.sql;
quit


java -jar bfa-0.0.1-SNAPSHOT-8734-3306-bestic.jar


docker export -o C:\Users\bfa\Desktop\Clipboard\bestic-bfa.tar bestic-bfa

docker import bestic-bfa.tar bestic-bfa:latest

docker run --name bestic-bfa -p 8734:8734 -it bestic-bfa:latest /bin/bash

service mysql start

java -jar bfa-0.0.1-SNAPSHOT-8734-3306-bestic.jar
posted @ 2022-06-01 21:31  蓝火BlueFlameAshe  阅读(139)  评论(0编辑  收藏  举报