{"id":1,"date":"2023-02-12T09:26:45","date_gmt":"2023-02-12T01:26:45","guid":{"rendered":"http:\/\/www.appblog.cn\/?p=1"},"modified":"2023-02-12T15:22:21","modified_gmt":"2023-02-12T07:22:21","slug":"centos7-install-mysql","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/12\/centos7-install-mysql\/","title":{"rendered":"CentOS 7\u4e0b\u5b89\u88c5MySQL"},"content":{"rendered":"<p>MySQL \u662f\u4e00\u79cd\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u5173\u8054\u6570\u636e\u5e93\u5c06\u6570\u636e\u4fdd\u5b58\u5728\u4e0d\u540c\u7684\u8868\u4e2d\uff0c\u800c\u4e0d\u662f\u5c06\u6240\u6709\u6570\u636e\u653e\u5728\u4e00\u4e2a\u5927\u4ed3\u5e93\u5185\uff0c\u8fd9\u6837\u5c31\u589e\u52a0\u4e86\u901f\u5ea6\u5e76\u63d0\u9ad8\u4e86\u7075\u6d3b\u6027\u3002MySQL \u6240\u4f7f\u7528\u7684 SQL \u8bed\u8a00\u662f\u7528\u4e8e\u8bbf\u95ee\u6570\u636e\u5e93\u7684\u6700\u5e38\u7528\u6807\u51c6\u5316\u8bed\u8a00\u3002MySQL \u8f6f\u4ef6\u91c7\u7528\u4e86\u53cc\u6388\u6743\u653f\u7b56\uff0c\u5206\u4e3a\u793e\u533a\u7248\u548c\u5546\u4e1a\u7248\uff0c\u7531\u4e8e\u5176\u4f53\u79ef\u5c0f\u3001\u901f\u5ea6\u5feb\u3001\u603b\u4f53\u62e5\u6709\u6210\u672c\u4f4e\uff0c\u5c24\u5176\u662f\u5f00\u653e\u6e90\u7801\u8fd9\u4e00\u7279\u70b9\uff0c\u4e00\u822c\u4e2d\u5c0f\u578b\u7f51\u7ad9\u7684\u5f00\u53d1\u90fd\u9009\u62e9 MySQL \u4f5c\u4e3a\u7f51\u7ad9\u6570\u636e\u5e93\u3002\u7531\u4e8e\u5176\u793e\u533a\u7248\u7684\u6027\u80fd\u5353\u8d8a\uff0c\u642d\u914d PHP \u548c Apache \u53ef\u7ec4\u6210\u826f\u597d\u7684\u5f00\u53d1\u73af\u5883\u3002<\/p>\n<ul>\n<li>\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><\/li>\n<li>\u4e2d\u79d1\u5927\u955c\u50cf\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/mirrors.ustc.edu.cn\/mysql-ftp\/Downloads\/\">http:\/\/mirrors.ustc.edu.cn\/mysql-ftp\/Downloads\/<\/a><\/li>\n<\/ul>\n<p><!-- more --><\/p>\n<h2>MySQL\u5b89\u88c5<\/h2>\n<h3>el7(CentOS 7)<\/h3>\n<pre><code class=\"language-bash\"># 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-5.7\/mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar\n# wget http:\/\/mirrors.ustc.edu.cn\/mysql-ftp\/Downloads\/MySQL-5.7\/mysql-5.7.21-linux-glibc2.12-x86_64.tar\n\n# yum install -y perl-Module-Install.noarch numactl libaio\n# tar -xf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar\n\n# rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm\n# rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm\n# rpm -ivh mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm\n# rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm  \/\/\u5b89\u88c5mysql\u5ba2\u6237\u7aef\n# rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm  \/\/\u5b89\u88c5mysql\u670d\u52a1\u7aef\n# rpm -ivh mysql-community-devel-5.7.21-1.el7.x86_64.rpm\n\n# 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# \/usr\/bin\/mysqladmin -uroot -p&#039;YI#O1FgF,ptN&#039; password &#039;123456&#039;  \/\/\u4fee\u6539root\u7528\u6237\u5bc6\u7801\n# \/usr\/bin\/mysqladmin -u root -h appblog password &#039;123456&#039;  \/\/\u521b\u5efa\u6570\u636e\u5e93\n\n\/\/\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\n# systemctl enable mysqld\n# systemctl daemon-reload<\/code><\/pre>\n<h3>el6(CentOS 6)<\/h3>\n<pre><code class=\"language-bash\"># wget http:\/\/mirrors.ustc.edu.cn\/mysql-ftp\/Downloads\/MySQL-5.7\/mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar\n# yum install -y perl-Module-Install.noarch numactl libaio\n# tar -xf mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar\n# rpm -ivh mysql-community-common-5.7.21-1.el6.x86_64.rpm\n# rpm -ivh mysql-community-libs-5.7.21-1.el6.x86_64.rpm\n# rpm -ivh mysql-community-libs-compat-5.7.21-1.el6.x86_64.rpm\n# rpm -ivh mysql-community-client-5.7.21-1.el6.x86_64.rpm\n# rpm -ivh mysql-community-server-5.7.21-1.el6.x86_64.rpm\n# rpm -ivh mysql-community-devel-5.7.21-1.el6.x86_64.rpm\n\n# service mysqld start  \/\/\u542f\u52a8MySQL\u670d\u52a1\n# service mysqld status  \/\/\u67e5\u770bMySQL\u8fd0\u884c\u72b6\u6001\n# service mysqld restart  \/\/\u91cd\u542fMySQL\u670d\u52a1\n# grep &quot;password&quot; \/var\/log\/mysqld.log  \/\/\u67e5\u770b\u9ed8\u8ba4root\u7528\u6237\u5bc6\u7801\n# \/usr\/bin\/mysqladmin -uroot -p&#039;YI#O1FgF,ptN&#039; password &#039;xxxxxx&#039;  \/\/\u4fee\u6539root\u7528\u6237\u5bc6\u7801<\/code><\/pre>\n<h2>my.ini\u914d\u7f6e<\/h2>\n<pre><code class=\"language-bash\">[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","protected":false},"excerpt":{"rendered":"<p>MySQL \u662f\u4e00\u79cd\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u5173\u8054\u6570\u636e\u5e93\u5c06\u6570\u636e\u4fdd\u5b58\u5728\u4e0d\u540c\u7684\u8868\u4e2d\uff0c\u800c\u4e0d\u662f\u5c06\u6240\u6709\u6570\u636e\u653e\u5728\u4e00\u4e2a\u5927\u4ed3\u5e93\u5185\uff0c\u8fd9 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[20],"class_list":["post-1","post","type-post","status-publish","format-standard","hentry","category-devops-base","tag-mysql"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1","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=1"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}