{"id":74,"date":"2023-02-12T21:37:54","date_gmt":"2023-02-12T13:37:54","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=74"},"modified":"2023-02-12T21:38:33","modified_gmt":"2023-02-12T13:38:33","slug":"centos-7-install-mysql-8","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/12\/centos-7-install-mysql-8\/","title":{"rendered":"CentOS 7\u4e0b\u5b89\u88c5MySQL 8"},"content":{"rendered":"<p>\u5b98\u65b9\u955c\u50cf\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/dev.mysql.com\/downloads\/mirrors.html\">http:\/\/dev.mysql.com\/downloads\/mirrors.html<\/a><br \/>\n\u4e2d\u79d1\u5927\u955c\u50cf\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/mirrors.ustc.edu.cn\/mysql-ftp\/Downloads\/MySQL-8.0\/\">http:\/\/mirrors.ustc.edu.cn\/mysql-ftp\/Downloads\/MySQL-8.0\/<\/a><\/p>\n<pre><code># rpm -qa | grep -i mysql  \/\/\u68c0\u67e5\u662f\u5426\u5df2\u5b89\u88c5MySQL\uff0cgrep\u7684-i\u9009\u9879\u8868\u793a\u5339\u914d\u65f6\u5ffd\u7565\u5927\u5c0f\u5199\n# rpm -qa | grep -i mariadb\nmariadb-libs-5.5.52-1.el7.x86_64\n# rpm -e mariadb-libs-5.5.52-1.el7.x86_64 --nodeps  \/\/\u5378\u8f7d\uff0c\u2013nodeps\u5ffd\u7565\u4f9d\u8d56\u5173\u7cfb\n\n# wget http:\/\/mirrors.ustc.edu.cn\/mysql-ftp\/Downloads\/MySQL-8.0\/mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar\n# wget http:\/\/mirrors.ustc.edu.cn\/mysql-ftp\/Downloads\/MySQL-8.0\/mysql-8.0.18-linux-glibc2.12-x86_64.tar\n\n# yum install -y perl-Module-Install.noarch numactl libaio\n# tar -xf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar\n\n# rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm\n# rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm\n# rpm -ivh mysql-community-libs-compat-8.0.18-1.el7.x86_64.rpm\n# rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm  \/\/\u5b89\u88c5mysql\u5ba2\u6237\u7aef\n# rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm  \/\/\u5b89\u88c5mysql\u670d\u52a1\u7aef\n# rpm -ivh mysql-community-devel-8.0.18-1.el7.x86_64.rpm<\/code><\/pre>\n<p>\u82e5\u62a5\u9519\uff1a<\/p>\n<pre><code># rpm -ivh mysql-community-devel-8.0.18-1.el7.x86_64.rpm\nwarning: mysql-community-devel-8.0.18-1.el7.x86_64.rpm: Header V3 DSA\/SHA1 Signature, key ID 5072e1f5: NOKEY\nerror: Failed dependencies:\n    pkgconfig(openssl) is needed by mysql-community-devel-8.0.18-1.el7.x86_64<\/code><\/pre>\n<p>\u89e3\u51b3\uff1a<\/p>\n<pre><code># yum install openssl-devel<\/code><\/pre>\n<pre><code># mysql -V\n# vim \/etc\/my.cnf  \/\/\u914d\u7f6emy.cnf\n\n# systemctl start mysqld  \/\/\u542f\u52a8MySQL\u670d\u52a1\n# systemctl status mysqld  \/\/\u67e5\u770bMySQL\u8fd0\u884c\u72b6\u6001\n# systemctl restart mysqld  \/\/\u91cd\u542fMySQL\u670d\u52a1\n# grep &quot;password&quot; \/var\/log\/mysqld.log  \/\/\u67e5\u770b\u9ed8\u8ba4root\u7528\u6237\u5bc6\u7801\n\n\/\/\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\n# systemctl enable mysqld\n# systemctl daemon-reload<\/code><\/pre>\n<pre><code>[mysqld]\n#\n# Remove leading # and set to the amount of RAM for the most important data\n# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.\n# innodb_buffer_pool_size = 128M\n#\n# Remove leading # to turn on a very important data integrity option: logging\n# changes to the binary log between backups.\n# log_bin\n#\n# Remove leading # to set options mainly useful for reporting servers.\n# The server defaults are faster for transactions and fast SELECTs.\n# Adjust sizes as needed, experiment to find the optimal values.\n# join_buffer_size = 128M\n# sort_buffer_size = 2M\n# read_rnd_buffer_size = 2M\ndatadir=\/data\/mysql\nsocket=\/var\/lib\/mysql\/mysql.sock\nport=3306\n\n# Disabling symbolic-links is recommended to prevent assorted security risks\nsymbolic-links=0\n\nlog-error=\/var\/log\/mysqld.log\npid-file=\/var\/run\/mysqld\/mysqld.pid\n\ncharacter_set_server=utf8    #\u8bbe\u7f6eMySQL\u670d\u52a1\u5668\u9ed8\u8ba4\u5b57\u7b26\u96c6\nexplicit_defaults_for_timestamp=true\n\n[client]\ndefault_character_set=utf8    #\u8bbe\u7f6eMySQL\u5ba2\u6237\u7aef\u9ed8\u8ba4\u5b57\u7b26\u96c6<\/code><\/pre>\n<blockquote>\n<p>\u6ce8\uff1aMySQL 8.0 \u4e4b\u524d\u7684\u7248\u672c\u4e2d\u52a0\u5bc6\u89c4\u5219\u662f<code>mysql_native_password<\/code>\uff0c\u800c\u5728MySQL 8.0 \u4e4b\u540e\uff0c\u52a0\u5bc6\u89c4\u5219\u9ed8\u8ba4\u662f<code>caching_sha2_password<\/code>\u3002\u800c\u5927\u90e8\u5206\u5df2\u7ecf\u4e0a\u7ebf\u7684\u5e94\u7528\u7a0b\u5e8f\u7684MySQL\u9a71\u52a8\u4e00\u822c\u4e0d\u652f\u6301<code>caching_sha2_password<\/code>\uff0c\u56e0\u6b64\u9700\u8981\u5c06 MySQL 8.0 \u7528\u6237\u767b\u5f55\u5bc6\u7801\u52a0\u5bc6\u89c4\u5219\u8fd8\u539f\u6210<code>mysql_native_password<\/code><\/p>\n<\/blockquote>\n<p>\u91cd\u7f6e<code>root@localhost<\/code>\u521d\u59cb\u5bc6\u7801<\/p>\n<pre><code class=\"language-sql\">> alter user &#039;root&#039;@&#039;localhost&#039; identified with mysql_native_password by &#039;new password&#039;;\n> flush privileges;<\/code><\/pre>\n<p>\u8bbe\u7f6e\u5141\u8bb8root\u7528\u6237\u8fdc\u7a0b\u8bbf\u95ee<\/p>\n<pre><code class=\"language-sql\">> create user &#039;root&#039;@&#039;%&#039; identified with mysql_native_password by &#039;new password&#039;;\n> grant all privileges on *.* to &#039;root&#039;@&#039;%&#039;;\n> flush privileges;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b98\u65b9\u955c\u50cf\uff1ahttp:\/\/dev.mysql.com\/downloads\/mirrors.html \u4e2d\u79d1\u5927\u955c\u50cf\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[20],"class_list":["post-74","post","type-post","status-publish","format-standard","hentry","category-java","tag-mysql"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=74"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/74\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}