{"id":20,"date":"2026-03-30T17:08:47","date_gmt":"2026-03-30T09:08:47","guid":{"rendered":"http:\/\/peishop.cn\/?p=20"},"modified":"2026-03-30T17:08:47","modified_gmt":"2026-03-30T09:08:47","slug":"mysql-8%e5%ae%89%e8%a3%85","status":"publish","type":"post","link":"https:\/\/peishop.cn\/index.php\/2026\/03\/30\/mysql-8%e5%ae%89%e8%a3%85\/","title":{"rendered":"mysql 8+\u5b89\u88c5"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5\u4e00\uff1a\u901a\u8fc7\u5b98\u65b9\u4ed3\u5e93\u5b89\u88c5\uff08\u63a8\u8350\uff09<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Ubuntu\/Debian<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>\u590d\u5236<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># 1. \u4e0b\u8f7d\u5b98\u65b9 MySQL APT \u4ed3\u5e93\nwget https:\/\/dev.mysql.com\/get\/mysql-apt-config_0.8.29-1_all.deb\n\n# \u5982\u679c\u65e0\u6cd5\u8bbf\u95ee\uff0c\u4f7f\u7528\u56fd\u5185\u955c\u50cf\uff1a\n# wget https:\/\/mirrors.tuna.tsinghua.edu.cn\/mysql\/apt\/ubuntu\/pool\/mysql-8.0\/m\/mysql-apt-config\/mysql-apt-config_0.8.29-1_all.deb\n\n# 2. \u5b89\u88c5\u4ed3\u5e93\u914d\u7f6e\nsudo dpkg -i mysql-apt-config_0.8.29-1_all.deb\n# \u5728\u51fa\u73b0\u7684\u754c\u9762\u4e2d\u9009\u62e9 MySQL 8.0 \u7248\u672c\uff0c\u6309\u786e\u5b9a\n\n# 3. \u66f4\u65b0\u5305\u5217\u8868\nsudo apt update\n\n# 4. \u5b89\u88c5 MySQL Server\nsudo apt install mysql-server\n\n# 5. \u5b89\u5168\u914d\u7f6e\nsudo mysql_secure_installation<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. CentOS\/RHEL\/Fedora<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>\u590d\u5236<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># 1. \u4e0b\u8f7d MySQL YUM \u4ed3\u5e93\nsudo yum install https:\/\/dev.mysql.com\/get\/mysql80-community-release-el7-5.noarch.rpm\n\n# 2. \u5bfc\u5165 GPG \u5bc6\u94a5\nsudo rpm --import https:\/\/repo.mysql.com\/RPM-GPG-KEY-mysql-2023\n\n# 3. \u5b89\u88c5 MySQL\nsudo yum install mysql-community-server\n\n# 4. \u542f\u52a8\u670d\u52a1\nsudo systemctl start mysqld\nsudo systemctl enable mysqld\n\n# 5. \u83b7\u53d6\u4e34\u65f6\u5bc6\u7801\nsudo grep 'temporary password' \/var\/log\/mysqld.log\n\n# 6. \u5b89\u5168\u914d\u7f6e\nsudo mysql_secure_installation<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5\u4e8c\uff1a\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5b89\u88c5\uff08\u7b80\u5355\u4f46\u53ef\u80fd\u4e0d\u662f\u6700\u65b0\uff09<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Ubuntu\/Debian\uff1a<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>\u590d\u5236<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Ubuntu 22.04+ \u9ed8\u8ba4\u4ed3\u5e93\u5305\u542b MySQL 8.0\nsudo apt update\nsudo apt install mysql-server<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">CentOS 8\/RHEL 8\uff1a<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>\u590d\u5236<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u542f\u7528 MySQL 8 \u6a21\u5757\nsudo dnf module disable mysql\nsudo dnf module enable mysql:8.0\nsudo dnf install mysql-community-server<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5\u4e09\uff1a\u4e8c\u8fdb\u5236\u5305\u5b89\u88c5\uff08\u624b\u52a8\u5b89\u88c5\u6700\u65b0\u7248\uff09<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>\u590d\u5236<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u4ece\u5b98\u7f51\u4e0b\u8f7d\nwget https:\/\/dev.mysql.com\/get\/Downloads\/MySQL-8.0\/mysql-8.0.36-linux-glibc2.17-x86_64.tar.xz\n\n# \u56fd\u5185\u955c\u50cf\uff08\u534e\u4e3a\u4e91\uff09\n# wget https:\/\/mirrors.huaweicloud.com\/mysql\/Downloads\/MySQL-8.0\/mysql-8.0.36-linux-glibc2.17-x86_64.tar.xz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u89e3\u538b\u5b89\u88c5<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>\u590d\u5236<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u89e3\u538b\ntar -xf mysql-8.0.36-linux-glibc2.17-x86_64.tar.xz\nsudo mv mysql-8.0.36-linux-glibc2.17-x86_64 \/usr\/local\/mysql\n\n# \u521b\u5efa\u7528\u6237\u548c\u7ec4\nsudo groupadd mysql\nsudo useradd -r -g mysql -s \/bin\/false mysql\n\n# \u521b\u5efa\u6570\u636e\u76ee\u5f55\nsudo mkdir -p \/usr\/local\/mysql\/data\nsudo chown -R mysql:mysql \/usr\/local\/mysql<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u521d\u59cb\u5316<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>\u590d\u5236<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/usr\/local\/mysql\nsudo bin\/mysqld --initialize --user=mysql\n# \u4fdd\u5b58\u663e\u793a\u7684\u4e34\u65f6\u5bc6\u7801\nsudo bin\/mysql_ssl_rsa_setup<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5\u56db\uff1a\u4f7f\u7528 Docker\uff08\u6700\u65b9\u4fbf\uff09<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u5feb\u901f\u542f\u52a8<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>\u590d\u5236<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u62c9\u53d6 MySQL 8 \u955c\u50cf\ndocker pull mysql:8.0\n\n# \u8fd0\u884c\u5bb9\u5668\ndocker run -d \\\n  --name mysql8 \\\n  -e MYSQL_ROOT_PASSWORD=your_password \\\n  -p 3306:3306 \\\n  -v mysql_data:\/var\/lib\/mysql \\\n  mysql:8.0 \\\n  --character-set-server=utf8mb4 \\\n  --collation-server=utf8mb4_unicode_ci<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u5e26\u914d\u7f6e\u6587\u4ef6\u7684 Docker<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>\u590d\u5236<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u521b\u5efa\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55\nmkdir -p ~\/mysql\/conf ~\/mysql\/data\n\n# \u521b\u5efa\u914d\u7f6e\u6587\u4ef6 ~\/mysql\/conf\/my.cnf\ncat &gt; ~\/mysql\/conf\/my.cnf &lt;&lt; 'EOF'\n<\/code><\/pre>\n\n\n<p>[mysqld]<\/p>\n\n\n\n<p>character-set-server=utf8mb4 collation-server=utf8mb4_unicode_ci default-authentication-plugin=mysql_native_password<\/p>\n\n\n<p>[client]<\/p>\n\n\n\n<p>default-character-set=utf8mb4 EOF # \u8fd0\u884c\u5bb9\u5668 docker run -d \\ &#8211;name mysql8 \\ -e MYSQL_ROOT_PASSWORD=123456 \\ -v ~\/mysql\/conf:\/etc\/mysql\/conf.d \\ -v ~\/mysql\/data:\/var\/lib\/mysql \\ -p 3306:3306 \\ mysql:8.0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u65b9\u6cd5\u4e00\uff1a\u901a\u8fc7\u5b98\u65b9\u4ed3\u5e93\u5b89\u88c5\uff08\u63a8\u8350\uff09 1. Ubuntu\/Debian bash bash \u590d\u5236 2. CentO [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/posts\/20"}],"collection":[{"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":1,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"predecessor-version":[{"id":21,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/posts\/20\/revisions\/21"}],"wp:attachment":[{"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}