MySQL雙主高可用詳解
主機(jī)規(guī)劃:
| 主機(jī)名稱 | IP | Keepalived | 操作系統(tǒng) | 安裝服務(wù) | 安裝路徑 |
|---|---|---|---|---|---|
| mysql01 | 192.168.91.61 | 192.168.91.100 | CentOS 7.9 | MySQL 8.0.28 Keepalived v1.3.5 | /usr/local/mysql |
| mysql02 | 192.168.91.62 | 192.168.91.100 | CentOS 7.9 | MySQL 8.0.28 Keepalived v1.3.5 | /usr/local/mysql |
架構(gòu)圖:

一、系統(tǒng)初基礎(chǔ)優(yōu)化(mysql01和mysql02都操作)
systemctl stop firewalld systemctl disable firewalld sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/selinux/config grep -i "^selinux=" /etc/selinux/config setenforce 0 getenforce cat >> /etc/security/limits.conf << EOF * soft nproc 65535 * hard nproc 65535 * soft nofile 65535 * hard nofile 65535 EOF cat >> /etc/hosts << EOF 192.168.91.61 mysql01 192.168.91.62 mysql02 EOF
二、腳本自動(dòng)安裝MySQL二進(jìn)制軟件包(mysql01和mysql02都操作)
1、下載MySQL二進(jìn)制軟件包
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz -P /mnt/
2、創(chuàng)建自動(dòng)安裝MySQL二進(jìn)制軟件包腳本
注意:此腳本只適合CentOS 7.9版本操作系統(tǒng)和MySQL 8.0版本數(shù)據(jù)庫安裝,MySQL二進(jìn)制軟件包一定要與自動(dòng)安裝腳本放在同一個(gè)目錄上執(zhí)行,否則執(zhí)行會(huì)報(bào)錯(cuò)。
[root@mysql01 ~]# vim /mnt/mysql_install.sh
#!/bin/bash
# Description: MySQL binary pack install
# Version: 1.0
#################################################################################
# Prompt: MySQL binary pack must put same directory with scripts.
# 提示: 把MySQL 二進(jìn)制軟件包與該腳本放在同一個(gè)目錄下,再執(zhí)行該腳本進(jìn)行安裝.
#################################################################################
. /etc/profile
export PATH=$PATH
RED='\033[1;31;5m'
RES='\033[0m'
MYSQL_COUNT=$(ss -tlunp | grep mysqld | wc -l)
MYSQL_PWD=$(pwd)
MYSQL_PACK="mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz" ### 只需要把這個(gè)軟件包名稱替換成你所下載的軟件包名稱一致
MYSQL_PATH="/usr/local/${MYSQL_PACK//-linux*/}"
MYSQL_LINK="/usr/local/mysql"
### check MySQL if installed
if [ $MYSQL_COUNT -ne 0 ];then
echo -e "${RED} MySQL program is running ${RES}"
exit 1
fi
### check MySQL directory is exits
if [ -d /usr/local/mysql* ];then
echo -e "${RED} MySQL directory is exits ${RES}"
exit 1
fi
### check MySQL binary pack if exist
if [ ! -f ${MYSQL_PWD}/${MYSQL_PACK} ];then
echo -e "${RED} Current directory is not MySQL binary pack,Please copy it ${RES}"
exit 1
fi
### install MySQL depend pack
yum -y install ncurses-devel libaio-devel gcc gcc++ net-tools > /dev/null 2>&1
if [ $? -ne 0 ];then
echo -e "${RED} Yum install is failure,Please check network if surf the internet ${RES}"
exit 1
fi
### discompress MySQL binary pack
tar xf ${MYSQL_PWD}/${MYSQL_PACK} -C /usr/local/
mv /usr/local/mysql-* ${MYSQL_PATH}
ln -s ${MYSQL_PATH} ${MYSQL_LINK}
mkdir -p ${MYSQL_LINK}/data
mkdir -p ${MYSQL_LINK}/logs
###judge my.cnf configuration file if exits
if [ -f /etc/my.cnf ];then
mv /etc/my.cnf /tmp/
fi
### compile my.cnf configuration file
cat << EOF > /etc/my.cnf
[mysqld]
#server-id=1
mysqlx_socket=/tmp/mysqlx.sock
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
pid_file=/tmp/mysqld.pid
log_error=/usr/local/mysql/logs/error.log
log-bin=/usr/local/mysql/logs/mysql.bin
character-set-server=utf8mb4
max_connections=500
max_connect_errors=1000
port=3306
mysqlx_port=33060
EOF
### create MySQL virtual user
id mysql > /dev/null 2>&1
if [ $? -ne 0 ];then
useradd -s /bin/nologin -M mysql
fi
### MySQL directory to mandate mysql user
chown -R mysql:mysql /usr/local/mysql*
### initialize MySQL
${MYSQL_LINK}/bin/mysqld --initialize --user=mysql --basedir=${MYSQL_LINK} --datadir=${MYSQL_LINK}/data
### copy MySQL boot scripts
cp ${MYSQL_LINK}/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
sed -i 's@^basedir=@basedir=/usr/local/mysql@g' /etc/init.d/mysqld
sed -i 's@^datadir=@datadir=/usr/local/mysql/data@g' /etc/init.d/mysqld
### MySQL take all command add system environment variable
cat << EOF >> /etc/profile
export PATH=$PATH:/usr/local/mysql/bin/
EOF
source /etc/profile
### MySQL start
/etc/init.d/mysqld start > /dev/null 2>&1
if [ $? -ne 0 ];then
echo -e "${RED} MySQL start is failure,Please check MySQL error-log ${RES}"
exit 1
fi
### grep MySQL initialize root password and modify root password is 123456
MYSQL_PASS=$(grep "A temporary password" /usr/local/mysql/logs/error.log | awk '{print $NF}')
${MYSQL_LINK}/bin/mysql --connect-expired-password -uroot -p${MYSQL_PASS} -e "alter user 'root'@'localhost' identified by '123456'"
### setup MySQL service auto start
cat << EOF >> /etc/rc.local
/etc/init.d/mysqld start
EOF
chmod +x /etc/rc.local
### echo MySQL password
echo -e "\n\n###############################################\n"
echo " MySQL root 密碼 123456"
echo " MySQL 服務(wù)啟動(dòng)命令 /etc/init.d/mysqld start"
echo " MySQL 命令生效請執(zhí)行命令 source /etc/profile"
echo -e "\n###############################################\n"
3、執(zhí)行自動(dòng)安裝MySQL二進(jìn)制軟件包腳本
chmod +x /mnt/mysql_install.sh cd /mnt/ sh mysql_install.sh
4、測試登錄MySQL數(shù)據(jù)庫
source /etc/profile mysql -uroot -p123456
三、配置mysql01和mysql02相互主從同步(mysql01和mysql02都操作)
1、登錄mysql01主機(jī)修改/etc/my.cnf配置文件
cat > /etc/my.cnf << EOF [client] # 設(shè)置MySQL客戶端連接端口 port=3306 # 設(shè)置MySQL客戶端連接sock socket=/usr/local/mysql/logs/mysql.sock # 設(shè)置MySQL客戶端編碼 default-character-set=utf8mb4 [mysqld] # 設(shè)置MySQL服務(wù)端TCP連接端口 port=3306 # 設(shè)置MySQL服務(wù)端SSL連接端口 mysqlx_port=33060 # 設(shè)置MySQL服務(wù)端編碼 character-set-server=utf8mb4 # MySQL服務(wù)端安裝目錄 basedir=/usr/local/mysql # MySQL服務(wù)端數(shù)據(jù)存放目錄 datadir=/usr/local/mysql/data # MySQL服務(wù)端socket文件地址 socket=/usr/local/mysql/logs/mysql.sock # MySQL服務(wù)端mysqlx.socket文件地址 mysqlx_socket=/usr/local/mysql/logs/mysqlx.sock # MySQL服務(wù)端PID文件地址 pid_file=/usr/local/mysql/logs/mysqld.pid # MySQL服務(wù)端錯(cuò)誤日志存儲(chǔ)地址 log_error=/usr/local/mysql/logs/error.log # 設(shè)置MySQL主從同步的server-id,每臺(tái)MySQL設(shè)置的server-id不能相同 server-id=100 # 設(shè)置MySQL主從同步bin-log存放路徑及名稱 log-bin=/usr/local/mysql/logs/mysql-bin # 設(shè)置MySQL主從同步方式,默認(rèn)row binlog_format=row # 保留最近604800秒(7天)bin-log日志(默認(rèn)秒為單位),默認(rèn)保留最近30天 binlog_expire_logs_seconds=604800 # 設(shè)置主鍵自增起始值,兩個(gè)master主庫不能設(shè)置相同的值,否則容易引起主鍵自增值沖突 auto_increment_offset=1 # 控制主鍵自增長每次遞增的量,用于防止Master主庫與Master主庫之間復(fù)制出現(xiàn)重復(fù)自增字段值,例如auto_increment_increment值與auto_increment_offset值組合使用,例如auto_increment_offset值等于1, auto_increment_increment值等于2,那么每次主鍵自增長值就是 1 3 5 7 9 11每次加2遞增的主鍵值 auto_increment_increment=2 EOF
2、登錄mysql02主機(jī)修改/etc/my.cnf配置文件
cat > /etc/my.cnf << EOF [client] # 設(shè)置MySQL客戶端連接端口 port=3306 # 設(shè)置MySQL客戶端連接sock socket=/usr/local/mysql/logs/mysql.sock # 設(shè)置MySQL客戶端編碼 default-character-set=utf8mb4 [mysqld] # 設(shè)置MySQL服務(wù)端TCP連接端口 port=3306 # 設(shè)置MySQL服務(wù)端SSL連接端口 mysqlx_port=33060 # 設(shè)置MySQL服務(wù)端編碼 character-set-server=utf8mb4 # MySQL服務(wù)端安裝目錄 basedir=/usr/local/mysql # MySQL服務(wù)端數(shù)據(jù)存放目錄 datadir=/usr/local/mysql/data # MySQL服務(wù)端socket文件地址 socket=/usr/local/mysql/logs/mysql.sock # MySQL服務(wù)端mysqlx.socket文件地址 mysqlx_socket=/usr/local/mysql/logs/mysqlx.sock # MySQL服務(wù)端PID文件地址 pid_file=/usr/local/mysql/logs/mysqld.pid # MySQL服務(wù)端錯(cuò)誤日志存儲(chǔ)地址 log_error=/usr/local/mysql/logs/error.log # 設(shè)置MySQL主從同步的server-id,每臺(tái)MySQL設(shè)置的server-id不能相同 server-id=200 # 設(shè)置MySQL主從同步bin-log存放路徑及名稱 log-bin=/usr/local/mysql/logs/mysql-bin # 設(shè)置MySQL主從同步方式,默認(rèn)row binlog_format=row # 保留最近604800秒(7天)bin-log日志(默認(rèn)秒為單位),默認(rèn)保留最近30天 binlog_expire_logs_seconds=604800 # 設(shè)置主鍵自增起始值,兩個(gè)master主庫不能設(shè)置相同的值,否則容易引起主鍵自增值沖突 auto_increment_offset=2 # 控制主鍵自增長每次遞增的量,用于防止Master主庫與Master主庫之間復(fù)制出現(xiàn)重復(fù)自增字段值,例如auto_increment_increment值與auto_increment_offset值組合使用,例如auto_increment_offset值等于2, auto_increment_increment值等于2,那么每次主鍵自增長值就是 2 4 6 8 10 12每次加2遞增的主鍵值 auto_increment_increment=2 EOF
3、登錄mysql01和mysql02分別重啟MySQL數(shù)據(jù)庫
/etc/init.d/mysqld restart
4、登錄mysql01和mysql02分別創(chuàng)建MySQL主從同步用戶
mysql -uroot -p123456 create user 'slaveuser'@'%' identified with mysql_native_password by '123456'; grant replication slave on *.* to 'slaveuser'@'%'; flush privileges; select user,host from mysql.user;
5、登錄mysql01查看master狀態(tài)下的file文件和position位置點(diǎn)信息
注意:本教程安裝的兩個(gè)MySQL數(shù)據(jù)庫都是初始化的數(shù)據(jù)庫,沒有任何生產(chǎn)數(shù)據(jù)
mysql> show master status\G;
*************************** 1. row ***************************
File: mysql-bin.000001
Position: 1951
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)
6、登錄mysql02配置從庫同步mysql01主庫信息
mysql -uroot -p123456 mysql> CHANGE MASTER TO MASTER_HOST='192.168.91.61', MASTER_PORT=3306,MASTER_USER='slaveuser',MASTER_PASSWORD='123456',MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=1951; Query OK, 0 rows affected, 9 warnings (0.01 sec) mysql> start slave; Query OK, 0 rows affected, 1 warning (0.00 sec) ### 主要看以下三個(gè)參數(shù)指標(biāo)即可 mysql> show slave status\G; Slave_IO_Running: Yes Slave_SQL_Running: Yes Seconds_Behind_Master: 0 ### Slave_IO_Running:Yes,這個(gè)表示I/O的線程狀態(tài),I/O線程負(fù)責(zé)從主庫中讀取Binlog日志,并將Binlog日志寫入從庫的中繼日志中,狀態(tài)為Yes表示I/O線程工作正常,否則異常。 ### Slave_SQL_Running:Yes,這個(gè)表示SQL的線程狀態(tài),SQL線程負(fù)責(zé)讀取中繼日志(relay-log)中的數(shù)據(jù)并轉(zhuǎn)換為SQL語句應(yīng)用到從數(shù)據(jù)庫中,狀態(tài)為Yes表示I/O線程工作正常,否則異常。 ### Seconds_Behind_Master:0,這個(gè)表示在復(fù)制過程中,從庫比主庫延遲的秒數(shù)。 ### CHANGE MASTER TO ### MASTER_HOST='192.168.91.61', #<==主庫的IP ### MASTER_PORT=3306, #<==主庫的端口 ### MASTER_USER='slaveuser', #<==主庫創(chuàng)建主從同步用戶 ### MASTER_PASSWORD='123456', #<==主庫創(chuàng)建主從同步用戶密碼 ### MASTER_LOG_FILE='mysql-bin.000001', #<==主庫show master status狀態(tài)的file值 ### MASTER_LOG_POS=1092; #<==主庫show master status狀態(tài)的position值
7、登錄mysql02查看master狀態(tài)下的file文件和position位置點(diǎn)信息
注意:本教程安裝的兩個(gè)MySQL數(shù)據(jù)庫都是初始化的數(shù)據(jù)庫,沒有任何生產(chǎn)數(shù)據(jù)
mysql> show master status\G;
*************************** 1. row ***************************
File: mysql-bin.000001
Position: 1725
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)
8、登錄mysql01配置從庫同步mysql02主庫信息
mysql -uroot -p123456 mysql> CHANGE MASTER TO MASTER_HOST='192.168.91.62', MASTER_PORT=3306,MASTER_USER='slaveuser',MASTER_PASSWORD='123456',MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=1725; Query OK, 0 rows affected, 9 warnings (0.01 sec) mysql> start slave; Query OK, 0 rows affected, 1 warning (0.01 sec) ### 主要看以下三個(gè)參數(shù)指標(biāo)即可 mysql> show slave status\G; Slave_IO_Running: Yes Slave_SQL_Running: Yes Seconds_Behind_Master: 0
9、MySQL數(shù)據(jù)庫雙主測試
### 登錄mysql01主機(jī)數(shù)據(jù)庫創(chuàng)建一個(gè)測試用戶testuser [root@mysql01 ~]# mysql -uroot -p123456 mysql> create user testuser@'%' identified by '123456'; mysql> select user,host from mysql.user where user='testuser'; +----------+------+ | user | host | +----------+------+ | testuser | % | +----------+------+ 1 row in set (0.00 sec) ### 登錄mysql02主機(jī)數(shù)據(jù)庫查看testuser測試用戶是否同步創(chuàng)建 [root@mysql02 ~]# mysql -uroot -p123456 mysql> select user,host from mysql.user where user='testuser'; +----------+------+ | user | host | +----------+------+ | testuser | % | +----------+------+ 1 row in set (0.00 sec) ### 登錄mysql02主機(jī)數(shù)據(jù)庫刪除testuser測試用戶 [root@mysql02 ~]# mysql -uroot -p123456 mysql> drop user testuser@'%'; Query OK, 0 rows affected (0.00 sec) mysql> select user,host from mysql.user where user='testuser'; Empty set (0.00 sec) ### 登錄mysql01主機(jī)數(shù)據(jù)庫查看testuser測試用戶是否同步刪除 [root@mysql01 ~]# mysql -uroot -p123456 mysql> select user,host from mysql.user where user='testuser'; Empty set (0.00 sec)
四、登錄mysql01和mysql02安裝配置keepalived服務(wù)
1、登錄mysql01安裝配置keepalived服務(wù)
yum -y install keepalived
mv /etc/keepalived/keepalived.conf /tmp/
### 修改keepalived服務(wù)配置文件,根據(jù)實(shí)際情況修改IP地址、網(wǎng)卡名稱、state參數(shù)值名稱要修改成MASTER、priority參數(shù)值越大,優(yōu)先級就越高,master優(yōu)先級要高于backup
cat > /etc/keepalived/keepalived.conf << 'EOF'
! Configuration File for keepalived
global_defs {
script_user root
notification_email {
lishi666@qq.com
}
notification_email_from xiaoming@qq.com
smtp_server mail.qq.com
smtp_connect_timeout 30
router_id LVS_MASTER
enable_script_security
}
vrrp_script check_mysql_port {
script "/data/scripts/check.sh"
interval 1
weight -5
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 92
priority 100
advert_int 1
notify_master "/data/scripts/notify.sh master"
notify_slave "/data/scripts/notify.sh backup"
notify_fault "/data/scripts/notify.sh fault"
unicast_src_ip 192.168.91.61
unicast_peer {
192.168.91.62
}
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.91.100
}
track_script {
check_mysql_port
}
}
EOF
### 配置SMTP發(fā)送郵件功能,設(shè)置個(gè)人的外網(wǎng)郵箱賬號,此郵件賬號主要用來發(fā)送郵件使用
cat > /etc/mail.rc << EOF
set from=xiaoming@qq.com
set smtp=mail.qq.com
set smtp-auth-user=xiaoming@qq.com
set smtp-auth-password=abc123456
set smtp-auth=login
EOF
### 創(chuàng)建keepalived服務(wù)檢測MySQL狀態(tài)是否正常的腳本
mkdir -p /data/scripts
cat > /data/scripts/check.sh << 'EOF'
#!/bin/bash
source /etc/profile
mysql_pid=`ps -ef|grep mysql |grep -v grep | awk '{print $2}' | wc -l`
if [ ${mysql_pid} -eq 0 ];then
systemctl stop keepalived
fi
EOF
### 創(chuàng)建keepalived故障郵件通知腳本,根據(jù)實(shí)際情況修改IP、主機(jī)名稱、收件人郵件地址
cat > /data/scripts/notify.sh << 'EOF'
#!/bin/bash
#接收者郵箱,多個(gè)以空格分隔
contact=(lishi666@qq.com)
#本機(jī)ip
HOST_IP=192.168.91.61
HOST_NAME=mysql01
notify() {
#郵件主題
mailsubject="MySQL Keepalived負(fù)載均衡VIP地址發(fā)生了轉(zhuǎn)移"
#郵件正文
description="事件描述:${HOST_IP} keepalived changed to be $1"
datebody="發(fā)生時(shí)間:$(date +'%F %T')"
hostnamebody="主機(jī)名稱:${HOST_IP}"
ipbody="主機(jī)IP: ${HOST_NAME}"
for receiver in ${contact[*]}
do
#發(fā)送郵件
echo -e "${description} ${hostbody} \n ${datebody} \n ${hostnamebody} \n ${ipbody}" | mail -s "$mailsubject" $receiver
done
}
case $1 in
master)
notify master
;;
backup)
notify backup
;;
fault)
notify fault
;;
*)
echo "Usage:{master|backup|fault}"
exit 1
;;
esac
EOF
chmod +x /data/scripts/*.sh
2、登錄mysql02安裝配置keepalived服務(wù)
yum -y install keepalived
mv /etc/keepalived/keepalived.conf /tmp/
### 修改keepalived服務(wù)配置文件,根據(jù)實(shí)際情況修改IP地址、網(wǎng)卡名稱、state參數(shù)值名稱要修改成BACKUP、priority參數(shù)值越大,優(yōu)先級就越高,backup優(yōu)先級要低于master
cat > /etc/keepalived/keepalived.conf << 'EOF'
! Configuration File for keepalived
global_defs {
script_user root
notification_email {
lishi666@qq.com
}
notification_email_from xiaoming@qq.com
smtp_server mail.qq.com
smtp_connect_timeout 30
router_id LVS_MASTER
enable_script_security
}
vrrp_script check_mysql_port {
script "/data/scripts/check.sh"
interval 1
weight -5
}
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 92
priority 60
advert_int 1
notify_master "/data/scripts/notify.sh master"
notify_slave "/data/scripts/notify.sh backup"
notify_fault "/data/scripts/notify.sh fault"
unicast_src_ip 192.168.91.62
unicast_peer {
192.168.91.61
}
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.91.100
}
track_script {
check_mysql_port
}
}
EOF
### 配置SMTP發(fā)送郵件功能,設(shè)置個(gè)人的外網(wǎng)郵箱賬號,此郵件賬號主要用來發(fā)送郵件使用
cat > /etc/mail.rc << EOF
set from=xiaoming@qq.com
set smtp=mail.qq.com
set smtp-auth-user=xiaoming@qq.com
set smtp-auth-password=abc123456
set smtp-auth=login
EOF
### 創(chuàng)建keepalived服務(wù)檢測MySQL狀態(tài)是否正常的腳本
mkdir -p /data/scripts
cat > /data/scripts/check.sh << 'EOF'
#!/bin/bash
source /etc/profile
mysql_pid=`ps -ef|grep mysql |grep -v grep | awk '{print $2}' | wc -l`
if [ ${mysql_pid} -eq 0 ];then
systemctl stop keepalived
fi
EOF
### 創(chuàng)建keepalived故障郵件通知腳本,根據(jù)實(shí)際情況修改IP、主機(jī)名稱、收件人郵件地址
cat > /data/scripts/notify.sh << 'EOF'
#!/bin/bash
#接收者郵箱,多個(gè)以空格分隔
contact=(lishi666@qq.com)
#本機(jī)ip
HOST_IP=192.168.91.62
HOST_NAME=mysql02
notify() {
#郵件主題
mailsubject="MySQL Keepalived負(fù)載均衡VIP地址發(fā)生了轉(zhuǎn)移"
#郵件正文
description="事件描述:${HOST_IP} keepalived changed to be $1"
datebody="發(fā)生時(shí)間:$(date +'%F %T')"
hostnamebody="主機(jī)名稱:${HOST_IP}"
ipbody="主機(jī)IP: ${HOST_NAME}"
for receiver in ${contact[*]}
do
#發(fā)送郵件
echo -e "${description} ${hostbody} \n ${datebody} \n ${hostnamebody} \n ${ipbody}" | mail -s "$mailsubject" $receiver
done
}
case $1 in
master)
notify master
;;
backup)
notify backup
;;
fault)
notify fault
;;
*)
echo "Usage:{master|backup|fault}"
exit 1
;;
esac
EOF
chmod +x /data/scripts/*.sh
3、登錄mysql01和mysql02啟動(dòng)keepalived服務(wù)
### 先登錄mysql01主機(jī)啟動(dòng)keepalived服務(wù) systemctl start keepalived systemctl status keepalived ip a | grep 192.168.91.100 ### 再登錄mysql02主機(jī)啟動(dòng)keepalived服務(wù) systemctl start keepalived systemctl status keepalived
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Mysql案例之GROUP_CONCAT函數(shù)的具體使用
本文詳細(xì)的介紹了MySQL中學(xué)生與學(xué)科多對多關(guān)聯(lián)場景下的排序問題,通過GROUP_CONCAT函數(shù)結(jié)合左連接和分組,一次性獲取每個(gè)學(xué)生首個(gè)學(xué)科名稱并排序,感興趣的可以了解一下2025-05-05
將MySQL的表數(shù)據(jù)全量導(dǎo)入clichhouse庫中
這篇文章主要介紹了將MySQL的表數(shù)據(jù)全量導(dǎo)入clichhouse庫中,詳細(xì)介紹全量導(dǎo)出MySQL數(shù)據(jù)到clickhouse表的相關(guān)內(nèi)容,需要的小伙伴可以參考一下2022-03-03
centos 6.5下 mysql-community-server. 5.7.18-1.el6安裝
這篇文章主要介紹了centos 6.5下 mysql-community-server. 5.7.18-1.el6安裝,需要的朋友可以參考下2017-04-04
mysql序號rownum行號實(shí)現(xiàn)方式
這篇文章主要介紹了mysql序號rownum行號實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12
正則表達(dá)式(REGEXP)與通配符(LIKE)的超詳細(xì)對比
正則表達(dá)式和通配符有許多相似的地方,但它們作用、用法、格式有許多差別,這篇文章主要介紹了正則表達(dá)式(REGEXP)與通配符(LIKE)的超詳細(xì)對比,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2025-07-07
詳解遠(yuǎn)程連接Mysql數(shù)據(jù)庫的問題(ERROR 2003 (HY000))
本篇文章是對遠(yuǎn)程連接Mysql數(shù)據(jù)庫的問題進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06

