CentOS7/8 MySQL 5.7/8.0 安装 文档中系统镜像下载地址 CentOS 7
系统版本:CentOS Linux release 7.9.2009 (Core)
CentOS Stream 8
MySQL 5.7 安装 CentOS 7 使用二进制包安装 安装路径根据实际情况修改
数据存放目录:/data/mysql/
安装路径:/usr/local/mysql/
日志路径:/usr/local/mysql/logs/
配置文件路径:/etc/my.cnf
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 cat > /etc/selinux/config <<-'EOF' SELINUX=disabled SELINUXTYPE=targeted EOF rpm -qa | grep mariadb rpm -e --nodeps mariadb-libs-5.5.35-3.el7.x86_64 rpm -qa | grep mariadb | xargs rpm -e --nodeps yum install -y libaio* libncurses* libtirpc-devel wget groupadd mysql useradd -s /usr/sbin/nologin -M -g mysql mysql wget https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-5.7.38-linux-glibc2.12-x86_64.tar tar -xvf mysql-5.7.38-linux-glibc2.12-x86_64.tar tar -zxvf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz mv mysql-5.7.38-linux-glibc2.12-x86_64/ mysql/mv mysql/ /usr/local/mkdir -p /data/mysql/mkdir -p /usr/local/mysql/logs/ touch /usr/local/mysql/mysqld.pidtouch /usr/local/mysql/logs/mysqld.logcat >> /etc/my.cnf <<-'EOF' [client] default-character-set=utf8mb4 [mysql] default-character-set=utf8mb4 [mysqld] skip-name-resolve basedir=/usr/local/mysql datadir=/data/mysql port = 3306 socket=/tmp/mysql.sock log-error=/usr/local/mysql/logs/mysqld.log pid-file=/usr/local/mysql/mysqld.pid server_id=1 max_allowed_packet=256M binlog-row-event-max-size=256m lower_case_table_names=1 sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' character_set_server=utf8mb4 collation_server=utf8mb4_unicode_ci log-bin=mysql-bin max_binlog_size=1G binlog_format=ROW binlog_row_image=full default-time-zone='+8:00' max_connections=1000 EOF chown -R mysql.mysql /usr/local/mysql/chown -R mysql.mysql /data/mysql/cat >> /etc/profile <<-'EOF' MYSQL_HOME=/usr/local/mysql export PATH=$MYSQL_HOME /bin:$PATH EOF source /etc/profilemysqld --defaults-file=/etc/my.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql cat /usr/local/mysql/logs/mysqld.log | grep passwordmysqld --defaults-file=/etc/my.cnf --user=mysql mysql --defaults-file=/etc/my.cnf -uroot -p alter user 'root' @'localhost' identified by 'root' ; flush privileges; use mysql; update user set host='%' where user='root' ; flush privileges; exit ;mysqladmin -u root -p shutdown cat >> /lib/systemd/system/mysql.service <<-'EOF' [Unit] Description=MySQL After=network.target syslog.target [Service] Type=simple User=mysql Group=mysql TimeoutSec=0 PermissionsStartOnly=true PIDFile=/usr/local/mysql/mysqld.pid ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql Restart=always RestartSec=5s PrivateTmp=false LimitNOFILE=65536 [Install] WantedBy=multi-user.target EOF chmod 644 /usr/lib/systemd/system/mysql.servicesystemctl daemon-reload systemctl start mysql systemctl enable mysql
源码方式编译安装 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 cat > /etc/selinux/config <<-'EOF' SELINUX=disabled SELINUXTYPE=targeted EOF rpm -qa | grep mariadb rpm -e --nodeps mariadb-libs-5.5.35-3.el7.x86_64 rpm -qa | grep mariadb | xargs rpm -e --nodeps mkdir -p /data/mysql/mkdir -p /usr/local/mysql/logs/ touch /usr/local/mysql/mysqld.pidtouch /usr/local/mysql/logs/mysqld.loggroupadd mysql useradd -s /usr/sbin/nologin -M -g mysql mysql yum install -y wget vim make cmake gcc gcc-c++ openssl openssl-devel ncurses ncurses-devel libaio* libncurses* libtirpc-devel cd /root/wget https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4.3/rpcsvc-proto-1.4.3.tar.xz xz -d rpcsvc-proto-1.4.3.tar.xz tar -xvf rpcsvc-proto-1.4.3.tar cd rpcsvc-proto-1.4.3/./configure make && make install cd /root/wget https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-boost-5.7.38.tar.gz tar -zxvf mysql-boost-5.7.38.tar.gz cd mysql-5.7.38mkdir build && cd buildcmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DBUILD_CONFIG=mysql_release \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DMYSQL_DATADIR=/data/mysql \ -DWITH_BOOST=../boost \ -DSYSCONFDIR=/etc \ -DMYSQL_TCP_PORT=3306 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_EXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DWITH_EMBEDDED_SERVER=1 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_DEBUG=0 \ -DWITH_SSL=system make -j4 && make -j4 install
卸载二进制包安装与源码编译安装 1 2 3 4 5 6 7 8 9 systemctl disable mysql systemctl stop mysql rm -rf /etc/my.cnfrm -rf /data/mysql/rm -rf /usr/local/mysql/rm -rf /usr/lib/systemd/system/mysql.servicesystemctl daemon-reload
yum 安装与卸载 官方文档:https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
默认数据存放目录:/var/lib/mysql/
默认配置文件路径:/etc/my.cnf
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 rpm -qa | grep mariadb rpm -qa | grep mariadb | xargs rpm -e --nodeps wget https://repo.mysql.com/mysql57-community-release-el7.rpm rpm -ivh mysql57-community-release-el7.rpm rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql yum install -y mysql-community-server systemctl start mysqld systemctl stop mysqld systemctl status mysqld systemctl enable mysqld cat /var/log/mysqld.log | grep passwordrpm -qa | grep mysql systemctl stop mysqld systemctl disable mysqld rpm -qa | grep mysql | xargs rpm -e --nodeps
CentOS Stream 8 参考CentOS 7系统下安装即可
Docker 开发测试环境可以推荐使用此方法安装,生产环境不推荐使用此方法安装
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 echo 'Asia/Shanghai' > /etc/timezonemkdir -p /srv/mysql/conf /srv/mysql/logs /srv/mysql/datacat >> /srv/mysql/conf/custom.cnf <<-'EOF' [mysqld] skip-name-resolve server_id=1 max_allowed_packet=256M binlog-row-event-max-size=256m lower_case_table_names=1 sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' character_set_server=utf8mb4 collation_server=utf8mb4_unicode_ci log-bin=mysql-bin max_binlog_size=1G binlog_format=ROW binlog_row_image=full default-time-zone='+8:00' max_connections=512 EOF docker run --net=host -d --name mysql --privileged --restart=always -v /srv/mysql/conf:/etc/mysql/conf.d -v /srv/mysql/logs:/var/log/mysql -v /srv/mysql/data:/var/lib/mysql -v /etc/timezone:/etc/timezone -e TZ=Asia/Shanghai -e MYSQL_ROOT_PASSWORD=root mysql:5.7
MySQL 8.0 安装 CentOS 7 使用二进制包安装 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 cat > /etc/selinux/config <<-'EOF' SELINUX=disabled SELINUXTYPE=targeted EOF rpm -qa | grep mariadb rpm -e --nodeps mariadb-libs-5.5.35-3.el7.x86_64 rpm -qa | grep mariadb | xargs rpm -e --nodeps yum install -y libaio* libncurses* libtirpc-devel wget groupadd mysql useradd -s /usr/sbin/nologin -M -g mysql mysql wget https://mirrors.aliyun.com/mysql/MySQL-8.0/mysql-8.0.29-linux-glibc2.12-x86_64.tar tar -xvf mysql-8.0.29-linux-glibc2.12-x86_64.tar tar -xJvf mysql-8.0.29-linux-glibc2.12-x86_64.tar.xz mv mysql-8.0.29-linux-glibc2.12-x86_64/ mysql/mv mysql/ /usr/local/mkdir -p /data/mysql/mkdir -p /usr/local/mysql/logs/ touch /usr/local/mysql/mysqld.pidtouch /usr/local/mysql/logs/mysqld.logcat >> /etc/my.cnf <<-'EOF' [client] default-character-set=utf8mb4 [mysql] default-character-set=utf8mb4 [mysqld] skip-name-resolve basedir=/usr/local/mysql datadir=/data/mysql port=3306 mysqlx_port=33060 socket=/tmp/mysql.sock log-error=/usr/local/mysql/logs/mysqld.log pid-file=/usr/local/mysql/mysqld.pid server_id=1 max_allowed_packet=256M binlog-row-event-max-size=256m lower_case_table_names=1 sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' character_set_server=utf8mb4 collation_server=utf8mb4_unicode_ci log-bin=mysql-bin max_binlog_size=1G binlog_format=ROW binlog_row_image=full default-time-zone='+8:00' max_connections=1000 EOF chown -R mysql.mysql /usr/local/mysql/chown -R mysql.mysql /data/mysql/cat >> /etc/profile <<-'EOF' MYSQL_HOME=/usr/local/mysql export PATH=$MYSQL_HOME /bin:$PATH EOF source /etc/profilemysqld --defaults-file=/etc/my.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql cat /usr/local/mysql/logs/mysqld.log | grep passwordmysqld --defaults-file=/etc/my.cnf --user=mysql mysql --defaults-file=/etc/my.cnf -uroot -p alter user 'root' @'localhost' identified by 'root' ; flush privileges; use mysql; update user set host='%' where user='root' ; flush privileges; exit ;mysqladmin -u root -p shutdown cat >> /lib/systemd/system/mysql.service <<-'EOF' [Unit] Description=MySQL After=network.target syslog.target [Service] Type=simple User=mysql Group=mysql TimeoutSec=0 PermissionsStartOnly=true PIDFile=/usr/local/mysql/mysqld.pid ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql Restart=always RestartSec=5s PrivateTmp=false LimitNOFILE=65536 [Install] WantedBy=multi-user.target EOF chmod 644 /usr/lib/systemd/system/mysql.servicesystemctl daemon-reload systemctl start mysql systemctl enable mysql
源码方式编译安装 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 cat > /etc/selinux/config <<-'EOF' SELINUX=disabled SELINUXTYPE=targeted EOF rpm -qa | grep mariadb rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64 rpm -qa | grep mariadb | xargs rpm -e --nodeps mkdir -p /data/mysql/mkdir -p /usr/local/mysql/logs/ touch /usr/local/mysql/mysqld.pidtouch /usr/local/mysql/logs/mysqld.loggroupadd mysql useradd -s /usr/sbin/nologin -M -g mysql mysql yum install -y epel-release yum install -y wget vim make gcc gcc-c++ openssl openssl-devel openssl-libs ncurses ncurses-devel libaio* libncurses* libtirpc-devel bison m4 bzip2 libudev-devel epel-release yum install -y cmake3 gcc -v yum -y install centos-release-scl yum -y install devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-binutils scl enable devtoolset-11 bash gcc -v cd /root/wget https://mirrors.aliyun.com/mysql/MySQL-8.0/mysql-boost-8.0.29.tar.gz tar -zxvf mysql-boost-8.0.29.tar.gz cd mysql-8.0.29mkdir build && cd buildcmake3 .. -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DBUILD_CONFIG=mysql_release \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DMYSQL_DATADIR=/data/mysql \ -DWITH_BOOST=../boost \ -DSYSCONFDIR=/etc \ -DMYSQL_TCP_PORT=3306 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_DEBUG=0 \ -DWITH_SSL=system \ -DFORCE_INSOURCE_BUILD=1 make -j4 && make -j4 install
yum源安装与卸载 官方文档:https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
默认数据存放目录:/var/lib/mysql/
默认配置文件路径:/etc/my.cnf
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 rpm -qa | grep mariadb rpm -qa | grep mariadb | xargs rpm -e --nodeps wget https://repo.mysql.com/mysql80-community-release-el7.rpm yum localinstall -y mysql80-community-release-el7.rpm rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql yum install -y mysql-community-server systemctl start mysqld systemctl stop mysqld systemctl status mysqld systemctl enable mysqld cat /var/log/mysqld.log | grep passwordrpm -qa | grep mysql systemctl stop mysqld systemctl disable mysqld rpm -qa | grep mysql | xargs rpm -e --nodeps
CentOS Stream 8 使用二进制包安装 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 cat > /etc/selinux/config <<-'EOF' SELINUX=disabled SELINUXTYPE=targeted EOF rpm -qa | grep mariadb rpm -e --nodeps mariadb-libs-5.5.35-3.el7.x86_64 rpm -qa | grep mariadb | xargs rpm -e --nodeps yum install -y libaio* libncurses* libtirpc* ncurses-compat-libs wget vim groupadd mysql useradd -s /usr/sbin/nologin -M -g mysql mysql wget https://mirrors.aliyun.com/mysql/MySQL-8.0/mysql-8.0.29-linux-glibc2.12-x86_64.tar tar -xvf mysql-8.0.29-linux-glibc2.12-x86_64.tar tar -xJvf mysql-8.0.29-linux-glibc2.12-x86_64.tar.xz mv mysql-8.0.29-linux-glibc2.12-x86_64/ mysql/mv mysql/ /usr/local/mkdir -p /data/mysql/mkdir -p /usr/local/mysql/logs/ touch /usr/local/mysql/mysqld.pidtouch /usr/local/mysql/logs/mysqld.logcat > /etc/my.cnf <<-'EOF' [client] default-character-set=utf8mb4 [mysql] default-character-set=utf8mb4 [mysqld] skip-name-resolve basedir=/usr/local/mysql datadir=/data/mysql port=3306 mysqlx_port=33060 socket=/tmp/mysql.sock log-error=/usr/local/mysql/logs/mysqld.log pid-file=/usr/local/mysql/mysqld.pid server_id=1 max_allowed_packet=256M binlog-row-event-max-size=256m lower_case_table_names=1 sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' character_set_server=utf8mb4 collation_server=utf8mb4_unicode_ci log-bin=mysql-bin max_binlog_size=1G binlog_format=ROW binlog_row_image=full default-time-zone='+8:00' max_connections=1000 EOF chown -R mysql.mysql /usr/local/mysql/chown -R mysql.mysql /data/mysql/cat >> /etc/profile <<-'EOF' MYSQL_HOME=/usr/local/mysql export PATH=$MYSQL_HOME /bin:$PATH EOF source /etc/profilemysqld --defaults-file=/etc/my.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql cat /usr/local/mysql/logs/mysqld.log | grep passwordmysqld --defaults-file=/etc/my.cnf --user=mysql mysql --defaults-file=/etc/my.cnf -uroot -p alter user 'root' @'localhost' identified by 'root' ; flush privileges; use mysql; update user set host='%' where user='root' ; flush privileges; exit ;mysqladmin -u root -p shutdown cat >> /lib/systemd/system/mysql.service <<-'EOF' [Unit] Description=MySQL After=network.target syslog.target [Service] Type=simple User=mysql Group=mysql TimeoutSec=0 PermissionsStartOnly=true PIDFile=/usr/local/mysql/mysqld.pid ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql Restart=always RestartSec=5s PrivateTmp=false LimitNOFILE=65536 [Install] WantedBy=multi-user.target EOF chmod 644 /usr/lib/systemd/system/mysql.servicesystemctl daemon-reload systemctl start mysql systemctl enable mysql
源码方式编译安装 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 cat > /etc/selinux/config <<-'EOF' SELINUX=disabled SELINUXTYPE=targeted EOF rpm -qa | grep mariadb rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64 rpm -qa | grep mariadb | xargs rpm -e --nodeps mkdir -p /data/mysql/mkdir -p /usr/local/mysql/logs/ touch /usr/local/mysql/mysqld.pidtouch /usr/local/mysql/logs/mysqld.loggroupadd mysql useradd -s /usr/sbin/nologin -M -g mysql mysql yum install -y wget vim make cmake gcc gcc-c++ openssl* ncurses* libaio* libncurses* libtirpc-devel bison m4 bzip2 libudev-devel gcc-toolset-11-gcc gcc-toolset-11-gcc-c++ gcc-toolset-11-binutils cd /root/wget https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4.3/rpcsvc-proto-1.4.3.tar.xz xz -d rpcsvc-proto-1.4.3.tar.xz tar -xvf rpcsvc-proto-1.4.3.tar cd rpcsvc-proto-1.4.3/./configure make && make install cd /root/wget https://mirrors.aliyun.com/mysql/MySQL-8.0/mysql-boost-8.0.29.tar.gz tar -zxvf mysql-boost-8.0.29.tar.gz cd mysql-8.0.29mkdir build && cd buildcmake3 .. -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DBUILD_CONFIG=mysql_release \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DMYSQL_DATADIR=/data/mysql \ -DWITH_BOOST=../boost \ -DSYSCONFDIR=/etc \ -DMYSQL_TCP_PORT=3306 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_DEBUG=0 \ -DWITH_SSL=system \ -DFORCE_INSOURCE_BUILD=1 make -j4 && make -j4 install
yum源安装与卸载 官方文档:https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
默认数据存放目录:/var/lib/mysql/
默认配置文件路径:/etc/my.cnf
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 yum module disable mysql wget https://repo.mysql.com/mysql80-community-release-el8.rpm yum install -y mysql80-community-release-el8.rpm yum install -y mysql-community-server systemctl start mysqld systemctl stop mysqld systemctl status mysqld systemctl enable mysqld cat /var/log/mysqld.log | grep passwordrpm -qa | grep mysql systemctl stop mysqld systemctl disable mysqld rpm -qa | grep mysql | xargs rpm -e --nodeps
Docker 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 echo 'Asia/Shanghai' > /etc/timezonemkdir -p /srv/mysql/conf /srv/mysql/logs /srv/mysql/datacat >> /srv/mysql/conf/custom.cnf <<-'EOF' [mysqld] port=3306 mysqlx_port=33060 skip-name-resolve server_id=1 max_allowed_packet=256M binlog-row-event-max-size=256m lower_case_table_names=1 sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' character_set_server=utf8mb4 collation_server=utf8mb4_unicode_ci log-bin=mysql-bin max_binlog_size=1G binlog_format=ROW binlog_row_image=full default-time-zone='+8:00' max_connections=512 EOF docker run --net=host -d --name mysql8 --privileged --restart=always -v /srv/mysql/conf:/etc/mysql/conf.d -v /srv/mysql/logs:/var/log/mysql -v /srv/mysql/data:/var/lib/mysql -v /etc/timezone:/etc/timezone -e TZ=Asia/Shanghai -e MYSQL_ROOT_PASSWORD=root mysql:8.0