开发中遇到的问题汇总:MySQL、linux

CSDN博客地址:https://blog.csdn.net/qq_35893033/article/details/128424069

MySQL

  • Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)
    • 数据库字符集问题
    • 连接数据库后,显示数据库字符集:show variables like ‘%char%’;

linux

  • source:not found (ls -l `which sh` 输出lrwxrwxrwx 1 root root 4 Apr 21 13:57 /bin/sh -> dash)

    • 需要重新软连接:参考
    • rm -f /bin/sh
    • ln -s /bin/bash /bin/sh
  • tail 输出中文乱码???

  • shell脚本传递参数中,若包含空格,会被分割

  • shell中启动多个jar包,并控制顺序。

    • 示例场景:SpringCloud服务启动
    • 按照正常的shell脚本启动:sh xx.sh
    • 参考地址
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    #!/bin/sh

    export EUREKA=fire-eureka-1.0-ALPHA.jar
    export CONFIG=fire-config-1.0-ALPHA.jar
    export GATEWAY=fire-gateway-1.0-ALPHA.jar
    export AUTH=fire-auth-service-1.0-ALPHA.jar

    export EUREKA_port=8761
    export CONFIG_port=4001
    export GATEWAY_port=9999
    export AUTH_port=3001

    case "$1" in

    start)
    ## 启动eureka
    echo "--------eureka 开始启动--------------"
    nohup java -jar $EUREKA >/dev/null 2>&1 &
    EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
    until [ -n "$EUREKA_pid" ]
    do
    EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
    done
    echo "EUREKA pid is $EUREKA_pid"
    echo "--------eureka 启动成功--------------"

    ## 启动config
    echo "--------开始启动CONFIG---------------"
    nohup java -jar $CONFIG >/dev/null 2>&1 &
    CONFIG_pid=`lsof -i:$CONFIG_port|grep "LISTEN"|awk '{print $2}'`
    until [ -n "$CONFIG_pid" ]
    do
    CONFIG_pid=`lsof -i:$CONFIG_port|grep "LISTEN"|awk '{print $2}'`
    done
    echo "CONFIG pid is $CONFIG_pid"
    echo "---------CONFIG 启动成功-----------"

    ## 启动gateway
    echo "--------开始启动GATEWAY---------------"
    nohup java -jar $GATEWAY >/dev/null 2>&1 &
    GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
    until [ -n "$GATEWAY_pid" ]
    do
    GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
    done
    echo "GATEWAY pid is $GATEWAY_pid"
    echo "---------GATEWAY 启动成功-----------"

    ## 启动auth
    echo "--------开始启动AUTH---------------"
    nohup java -jar $AUTH >/dev/null 2>&1 &
    AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
    until [ -n "$AUTH_pid" ]
    do
    AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
    done
    echo "AUTH pid is $AUTH_pid"
    echo "---------AUTH 启动成功-----------"

    echo "===startAll success==="
    ;;

    stop)
    P_ID=`ps -ef | grep -w $EUREKA | grep -v "grep" | awk '{print $2}'`
    if [ "$P_ID" == "" ]; then
    echo "===EUREKA process not exists or stop success"
    else
    kill -9 $P_ID
    echo "EUREKA killed success"
    fi
    P_ID=`ps -ef | grep -w $CONFIG | grep -v "grep" | awk '{print $2}'`
    if [ "$P_ID" == "" ]; then
    echo "===CONFIG process not exists or stop success"
    else
    kill -9 $P_ID
    echo "CONFIG killed success"
    fi
    P_ID=`ps -ef | grep -w $GATEWAY | grep -v "grep" | awk '{print $2}'`
    if [ "$P_ID" == "" ]; then
    echo "===GATEWAY process not exists or stop success"
    else
    kill -9 $P_ID
    echo "GATEWAY killed success"
    fi
    P_ID=`ps -ef | grep -w $AUTH | grep -v "grep" | awk '{print $2}'`
    if [ "$P_ID" == "" ]; then
    echo "===AUTH process not exists or stop success"
    else
    kill -9 $P_ID
    echo "AUTH killed success"
    fi

    echo "===stop success==="
    ;;

    restart)
    $0 stop
    sleep 2
    $0 start
    echo "===restart success==="
    ;;
    esac
    exit 0
------ 本文结束感谢您的阅读 ------

本文标题:开发中遇到的问题汇总:MySQL、linux

文章作者:MangoCheng

发布时间:2022年12月23日 - 20:38:53

最后更新:2023年03月04日 - 08:41:00

原始链接:http://mangocheng.com/posts/94616ccb.html

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。