{"id":1088,"date":"2021-07-10T15:25:25","date_gmt":"2021-07-10T07:25:25","guid":{"rendered":"https:\/\/www.linuxdevops.cn\/?p=1088"},"modified":"2023-04-07T09:56:26","modified_gmt":"2023-04-07T01:56:26","slug":"installation-and-configuration-of-mysql-5-7-source-code","status":"publish","type":"post","link":"https:\/\/www.linuxdevops.cn\/2021\/07\/installation-and-configuration-of-mysql-5-7-source-code\/","title":{"rendered":"MySQL5.7 \u6e90\u7801\u5b89\u88c5\u914d\u7f6e"},"content":{"rendered":"
CMake<\/strong>\uff0c\u5728\u6240\u6709\u5e73\u53f0\u4e0a\u7528\u4f5c\u6784\u5efa\u6846\u67b6\u3002<\/p>\n<\/li>\n \u4e00\u4e2a\u6709\u6548\u7684 ANSI C++ \u7f16\u8bd1\u5668 gcc gcc-c++ ...<\/p>\n<\/li>\n \u9700\u8981 SSL \u5e93\u6765\u652f\u6301\u52a0\u5bc6\u8fde\u63a5\u3001\u968f\u673a\u6570\u751f\u6210\u7684\u71b5\u4ee5\u53ca\u5176\u4ed6\u4e0e\u52a0\u5bc6\u76f8\u5173\u7684\u64cd\u4f5c\u3002<\/p>\n<\/li>\n \u9700\u8981 Boost C++ \u5e93\u6765\u6784\u5efa MySQL\uff08\u4f46\u4e0d\u4f7f\u7528\u5b83\uff09\u3002\u5fc5\u987b\u5b89\u88c5 Boost 1.59.0\u3002\u8981\u83b7\u53d6 Boost \u53ca\u5176\u5b89\u88c5\u8bf4\u660e\uff0c\u8bf7\u8bbf\u95ee \u5b98\u65b9\u7f51\u7ad9<\/a>\u3002\u5b89\u88c5 Boost \u540e\uff0c\u901a\u8fc7 Boost 1.59.0 \u4e5f\u53ef\u4ee5\u4e0d\u5355\u72ec\u5b89\u88c5\uff0c\u5728\u7f16\u8bd1MySQL\u7684\u65f6\u5019\u52a0\u4e0a -DDOWNLOAD_BOOST=1<\/strong> \u4f1a\u81ea\u52a8\u4e0b\u8f7d\u5e93\u6587\u4ef6\u3002<\/p>\n<\/li>\n<\/ul>\n \u200b \u66f4\u591aMysql\u7f16\u8bd1\u914d\u7f6e\u9879<\/a><\/p>\n \u5b89\u88c5\u540e\u8bbe\u7f6e\u5305\u62ec\u4e3a\u5bfc\u5165\u548c\u5bfc\u51fa\u64cd\u4f5c\u521b\u5efa\u5b89\u5168\u76ee\u5f55\u3001\u914d\u7f6e\u670d\u52a1\u5668\u542f\u52a8\u9009\u9879\u3001\u521d\u59cb\u5316\u6570\u636e\u76ee\u5f55\u3001\u4f7f\u7528 systemd \u542f\u52a8 MySQL\u3001\u91cd\u7f6e MySQL \u8981\u9650\u5236 \u901a\u8fc7\u5c06\u9009\u9879\u653e\u5728 MySQL \u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6307\u5b9a MySQL \u670d\u52a1\u5668\u5728\u542f\u52a8\u65f6\u5e94\u4f7f\u7528\u7684\u9009\u9879\u3002\u5982\u679c\u60a8\u4e0d\u8fd9\u6837\u505a\uff0c\u670d\u52a1\u5668\u5c06\u4ee5\u5176\u9ed8\u8ba4\u8bbe\u7f6e\u542f\u52a8\uff08\u8bf7\u53c2\u9605 \u670d\u52a1\u5668\u914d\u7f6e\u9ed8\u8ba4\u503c<\/a>\uff09\u3002<\/p>\n \u67d0\u4e9b \u8981\u521b\u5efa MySQL \u914d\u7f6e\u6587\u4ef6\uff0c\u8bf7\u4ee5 root \u8eab\u4efd\u53d1\u51fa\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n \u5982\u679c \u5728 MySQL \u6570\u636e\u76ee\u5f55\u7684\u4f4d\u7f6e\u5bf9\u4e8e MySQL \u5b89\u88c5\u7684\u5b89\u5168\u6027\u81f3\u5173\u91cd\u8981\u3002\u9664\u4e86\u7528\u6237\u6570\u636e\u5916\uff0c\u6570\u636e\u76ee\u5f55\u8fd8\u5305\u542b\u6570\u636e\u5b57\u5178\u548c\u7cfb\u7edf\u8868\uff0c\u5176\u4e2d\u5b58\u50a8\u4e86\u6709\u5173\u6570\u636e\u5e93\u5bf9\u8c61\u3001\u7528\u6237\u3001\u6743\u9650\u7b49\u654f\u611f\u4fe1\u606f\u3002\u9075\u5faa\u6700\u5c0f\u6743\u9650\u539f\u5219\uff0c\u7cfb\u7edf\u7528\u6237\u5bf9\u6570\u636e\u76ee\u5f55\u7684\u8bbf\u95ee\u5e94\u5c3d\u53ef\u80fd\u53d7\u5230\u9650\u5236\u3002\u8fd8\u5e94\u8003\u8651\u6570\u636e\u76ee\u5f55\u6240\u5728\u7684\u6587\u4ef6\u7cfb\u7edf\u7684\u5927\u5c0f\u3002\u786e\u4fdd\u6587\u4ef6\u7cfb\u7edf\u53ef\u4ee5\u5bb9\u7eb3\u9884\u671f\u7684\u6570\u636e\u5927\u5c0f\u3002\u672c\u6307\u5357\u4e2d\u63cf\u8ff0\u7684\u90e8\u7f72\u5c06\u6570\u636e\u76ee\u5f55\u653e\u7f6e\u5728\u9ed8\u8ba4\u4f4d\u7f6e ( \u8bbe\u7f6e \u5982\u679c\u60a8\u6253\u7b97\u5141\u8bb8\u5bfc\u5165\u548c\u5bfc\u51fa\u64cd\u4f5c\uff0c\u8bf7\u5c06 \u4e3a\u907f\u514d \u6709\u5173\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 LOAD DATA LOCAL \u7684\u5b89\u5168\u6ce8\u610f\u4e8b\u9879<\/a>\u3002<\/p>\n<\/li>\n<\/ol>\n \u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0c\u914d\u7f6e\u6587\u4ef6\u5e94\u8be5\u5305\u542b\u8fd9\u4e9b\u8bbe\u7f6e\uff0c\u5047\u8bbe\u60a8\u8fd8\u6ca1\u6709\u6dfb\u52a0\u5176\u4ed6\u8bbe\u7f6e\uff1a<\/p>\n \u5b89\u88c5MySQL\u540e\uff0c\u5fc5\u987b\u521d\u59cb\u5316\u6570\u636e\u76ee\u5f55\uff0c\u5176\u4e2d\u5305\u62ec \u521d\u59cb\u5316\u6570\u636e\u76ee\u5f55\uff1a<\/p>\n \u5c06\u4f4d\u7f6e\u66f4\u6539\u4e3a MySQL \u5b89\u88c5\u7684\u9876\u7ea7\u76ee\u5f55\uff0c\u521b\u5efa\u6570\u636e\u76ee\u5f55\uff0c\u5e76\u5c06\u6240\u6709\u6743\u6388\u4e88 \u6570\u636e\u76ee\u5f55\u6240\u6709\u6743\u5df2\u5206\u914d\u7ed9 \u521d\u59cb\u5316\u6570\u636e\u76ee\u5f55\u3002<\/p>\n \u521d\u59cb\u5316\u8f93\u51fa\u4f1a\u6253\u5370\u5230\u9519\u8bef\u65e5\u5fd7 ( \u6570\u636e\u76ee\u5f55\u521d\u59cb\u5316\u5728 \u6709\u5173\u6570\u636e\u76ee\u5f55\u521d\u59cb\u5316\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 \u521d\u59cb\u5316\u6570\u636e\u76ee\u5f55<\/a>\u3002<\/p>\n \u672c\u8282\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 systemd \u542f\u52a8\u670d\u52a1\u5668\uff0c\u4ee5\u53ca\u5982\u4f55\u5728\u4e3b\u673a\u91cd\u542f\u65f6\u542f\u7528 MySQL \u670d\u52a1\u5668\u7684\u81ea\u52a8\u91cd\u542f\u3002<\/p>\n systemd \u4f7f\u7528systemctl<\/strong>\u547d\u4ee4\u63d0\u4f9b\u624b\u52a8\u670d\u52a1\u5668\u7ba1\u7406 \uff1a<\/p>\n \u5c06 MySQL \u5b89\u88c5\u914d\u7f6e\u4e3a\u4e0e systemd \u4e00\u8d77\u4f7f\u7528\uff1a<\/p>\n \u6dfb\u52a0 systemd \u670d\u52a1\u5355\u5143\u914d\u7f6e\u6587\u4ef6\uff0c\u5176\u4e2d\u5305\u542b\u6709\u5173 MySQL \u670d\u52a1\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u8be5\u6587\u4ef6\u88ab\u547d\u540d \u5c06\u6b64\u914d\u7f6e\u4fe1\u606f\u6dfb\u52a0\u5230 \u4e3a systemd \u5c06\u6b64\u914d\u7f6e\u4fe1\u606f\u6dfb\u52a0\u5230 \u4f7f \u4e3a\u786e\u4fdd systemd \u914d\u7f6e\u6709\u6548\uff0c\u8bf7 \u68c0\u67e5 \u8981\u9a8c\u8bc1 systemd \u5728\u7cfb\u7edf\u91cd\u65b0\u542f\u52a8\u65f6\u662f\u5426\u81ea\u52a8\u542f\u52a8 MySQL\uff0c\u8bf7\u91cd\u65b0\u542f\u52a8\u7cfb\u7edf\u5e76 systemd \u6709\u81ea\u5df1\u7684\u65e5\u5fd7\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528journalctl<\/strong>\u8bbf\u95ee \u3002\u8981\u67e5\u770b\u4e0e mysqld \u76f8\u5173\u7684\u65e5\u5fd7\u6d88\u606f\uff0c\u8bf7\u4f7f\u7528 \u6709\u5173 systemd \u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 \u4f7f\u7528 systemd \u7ba1\u7406 MySQL \u670d\u52a1\u5668<\/a>\u3002<\/p>\n \u6b64\u8fc7\u7a0b\u5047\u8bbe MySQL \u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u53d1\u51fa\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5\u670d\u52a1\u5668\u72b6\u6001\uff1a<\/p>\n \u521d\u59cb\u5316\u6570\u636e\u76ee\u5f55\u65f6\uff0c\u4f1a\u4e3a MySQL \u4f7f\u7528 \u8fde\u63a5\u540e\uff0c\u5206\u914d\u4e00\u4e2a\u65b0 \u6216\u8005\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u8be5 \u65e2\u7136 MySQL \u5df2\u5b89\u88c5\u5e76\u521d\u59cb\u5316\uff0c\u5e76\u4e14 MySQL WITH_BOOST<\/code><\/a>\u5728\u8c03\u7528CMake<\/strong>\u65f6\u5b9a\u4e49\u9009\u9879\u6765\u544a\u8bc9\u6784\u5efa\u7cfb\u7edf Boost \u6587\u4ef6\u6240\u5728\u7684\u4f4d\u7f6e \u3002\u4f8b\u5982\uff1a<\/p>\n
cmake . -DWITH_BOOST=\/usr\/local\/boost_1_59_0<\/code><\/pre>\n
\u4e0b\u8f7d\u7f16\u8bd1\u9700\u8981\u7684\u8f6f\u4ef6<\/h3>\n
yum install gcc gcc-c++ ncurses-devel cmake bison wget openssl-devel openssl <\/code><\/pre>\n
\u7f16\u8bd1\u5b89\u88c5MySQL<\/h1>\n
#\u521b\u5efa\u7528\u6237\uff0c\ngroupadd mysql\nuseradd -r -g mysql -s \/bin\/false mysql\n#\u4e0b\u8f7d\u6e90\u7801\nwget https:\/\/github.com\/mysql\/mysql-server\/archive\/refs\/tags\/mysql-5.7.34.tar.gz\n#\u89e3\u538b\u7f29\u5230\u60a8\u9009\u62e9\u7684\u5b89\u88c5\u4f4d\u7f6e\uff08\u901a\u5e38\u4e3a\/usr\/local\/mysql\uff09\ntar -zxvf mysql-5.7.34.tar.gz -C \/usr\/local\/\n#\u6539\u4e2a\u540d\n mv \/usr\/local\/mysql-server-mysql-5.7.34\/ \/usr\/local\/mysql<\/code><\/pre>\n
#\u8fdb\u5165\u76ee\u5f55\ncd \/usr\/local\/mysql\n#\u7f16\u8bd1\u5b89\u88c5Mysql\n cmake -DDOWNLOAD_BOOST=1 \\\n -DDOWNLOAD_BOOST_TIMEOUT=999999 \\\n -DWITH_BOOST=\/usr\/local \\\n -DCMAKE_INSTALL_PREFIX=\/usr\/local\/mysql \\\n -DMYSQL_UNIX_ADDR=\/usr\/local\/mysql\/mysql.sock \\\n -DDEFAULT_CHARSET=utf8 \\\n -DDEFAULT_COLLATION=utf8_general_ci \\\n -DMYSQL_DATADIR=\/usr\/local\/mysql\/data \\\n -DWITH_SYSTEMD=1 \\\n -DMYSQL_TCP_PORT=3306 && \\\n make && make install<\/code><\/pre>\n
##\u53c2\u6570\u8be6\u89e3\n -DDOWNLOAD_BOOST=1 #\u81ea\u52a8\u4e0b\u8f7dBoost\u5e93\n -DDOWNLOAD_BOOST_TIMEOUT=999999 #\u4e0b\u8f7d\u8d85\u65f6\u65f6\u95f4\uff08\u79d2\uff09\n -DWITH_BOOST=\/usr\/local #Boost \u5e93\u6e90\u7684\u4f4d\u7f6e\n -DCMAKE_INSTALL_PREFIX=\/usr\/local\/mysql #\u5b89\u88c5\u76ee\u5f55\n -DMYSQL_UNIX_ADDR=\/usr\/local\/mysql\/mysql.sock #sock \u76ee\u5f55\n -DDEFAULT_CHARSET=utf8 #\u9ed8\u8ba4\u670d\u52a1\u5668\u5b57\u7b26\u96c6\n -DDEFAULT_COLLATION=utf8_general_ci #\u9ed8\u8ba4\u670d\u52a1\u5668\u6392\u5e8f\u89c4\u5219\n -DMYSQL_DATADIR=\/usr\/local\/mysql\/data # \u6570\u636e\u76ee\u5f55\n -DWITH_SYSTEMD=1 # \u914d\u7f6e\u652f\u6301systemctl \u7ba1\u7406\u9009\u9879\n -DMYSQL_TCP_PORT=3306 #\u7aef\u53e3 <\/code><\/pre>\n
\u5b89\u88c5\u540e\u8bbe\u7f6e<\/h1>\n
root@localhost<\/code>\u7528\u6237\u5e10\u6237\u7684\u5bc6\u7801 \uff0c\u4ee5\u53ca\u8fd0\u884c\u4e00\u4e9b\u6d4b\u8bd5\u4ee5\u786e\u4fdd\u670d\u52a1\u5668\u6b63\u5e38\u3002<\/p>\n
\n
\u4e3a\u5bfc\u5165\u548c\u5bfc\u51fa\u64cd\u4f5c\u521b\u5efa\u5b89\u5168\u76ee\u5f55<\/h3>\n
FILE<\/code><\/a> \u6709\u6743\u9650\u7684 MySQL\u7528\u6237\u53ef\u4ee5\u4f7f\u7528
LOAD DATA INFILE<\/code><\/a>and
SELECT ... INTO OUTFILE<\/code><\/a>\u8bed\u53e5\u548c
LOAD_FILE()<\/code><\/a>\u51fd\u6570\u5728\u670d\u52a1\u5668\u4e3b\u673a\u4e0a\u8bfb\u5199\u6587\u4ef6\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5177\u6709
FILE<\/code><\/a>\u6743\u9650\u7684\u7528\u6237\u53ef\u4ee5\u8bfb\u53d6\u670d\u52a1\u5668\u4e3b\u673a\u4e0a\u4efb\u4f55\u4e16\u754c\u53ef\u8bfb\u6216 MySQL \u670d\u52a1\u5668\u53ef\u8bfb\u7684\u6587\u4ef6\u3002\uff08\u8fd9\u610f\u5473\u7740\u7528\u6237\u53ef\u4ee5\u8bfb\u53d6\u4efb\u4f55\u6570\u636e\u5e93\u76ee\u5f55\u4e2d\u7684\u4efb\u4f55\u6587\u4ef6\uff0c\u56e0\u4e3a\u670d\u52a1\u5668\u53ef\u4ee5\u8bbf\u95ee\u8fd9\u4e9b\u6587\u4ef6\u4e2d\u7684\u4efb\u4f55\u4e00\u4e2a\u3002\uff09\u8be5
FILE<\/code><\/a>\u6743\u9650\u8fd8\u4f7f\u7528\u6237\u80fd\u591f\u5728 MySQL \u670d\u52a1\u5668\u5177\u6709\u5199\u8bbf\u95ee\u6743\u9650\u7684\u4efb\u4f55\u76ee\u5f55\u4e2d\u521b\u5efa\u65b0\u6587\u4ef6\u3002\u8fd9\u5305\u62ec\u5305\u542b\u5b9e\u73b0\u6743\u9650\u8868\u7684\u6587\u4ef6\u7684\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u3002<\/p>\n
FILE<\/code><\/a> \u6743\u9650\u7684\u8303\u56f4\uff0c\u8bf7\u521b\u5efa\u4e00\u4e2a\u76ee\u5f55\uff0c\u5177\u6709\u8be5
FILE<\/code><\/a>\u6743\u9650\u7684\u7528\u6237 \u53ef\u4ee5\u5b89\u5168\u5730\u7528\u4e8e\u5bfc\u5165\u548c\u5bfc\u51fa\u64cd\u4f5c\u3002\u5728\u6b64\u90e8\u7f72\u4e2d\uff0c\u521b\u5efa\u7684\u76ee\u5f55\u5df2\u547d\u540d
mysql-files<\/code>\u5e76\u4f4d\u4e8e\u6570\u636e\u76ee\u5f55\u4e0b\u3002\u5728\u540e\u9762\u7684\u6b65\u9aa4\u4e2d\uff0c\u5f53\u914d\u7f6e\u670d\u52a1\u5668\u542f\u52a8\u9009\u9879\u65f6\uff0c\u8be5
secure_file_priv<\/code><\/a>\u9009\u9879\u5c06\u8bbe\u7f6e\u4e3a
mysql-files<\/code>\u76ee\u5f55\u3002<\/p>\n
shell> cd \/usr\/local\/mysql \nshell> mkdir mysql-files\nshell> chown mysql:mysql mysql-files\nshell> chmod 750 mysql-files<\/code><\/pre>\n
\u914d\u7f6e\u670d\u52a1\u5668\u542f\u52a8\u9009\u9879<\/h3>\n
\n
InnoDB<\/code>\u9009\u9879\u53ea\u80fd\u5728\u521d\u59cb\u5316\u6570\u636e\u76ee\u5f55\u4e4b\u524d\u914d\u7f6e\u3002\u5728\u8fd9\u4e9b\u9009\u9879\u4e2d\u6709
innodb_data_home_dir<\/code><\/a>\uff0c
innodb_data_file_path<\/code><\/a>\uff0c
innodb_log_file_size<\/code><\/a>\uff0c
innodb_log_group_home_dir<\/code><\/a>\uff0c\u548c
innodb_page_size<\/code><\/a>\u3002\u5982\u679c\u60a8\u4e0d\u60f3\u4e3a\u8fd9\u4e9b\u9009\u9879\u4f7f\u7528\u9ed8\u8ba4\u503c\uff0c\u8bf7\u5728\u521d\u59cb\u5316\u6570\u636e\u76ee\u5f55\u4e4b\u524d\u5728 MySQL \u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u60a8\u81ea\u5df1\u7684\u503c\u3002\u6b64\u90e8\u7f72\u4f7f\u7528\u9ed8\u8ba4
InnoDB<\/code>\u914d\u7f6e\u8bbe\u7f6e\u3002\u6709\u5173\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 InnoDB \u542f\u52a8\u914d\u7f6e<\/a>\u3002<\/p>\n<\/blockquote>\n
\n
shell> cd \/etc\nshell> touch my.cnf\nshell> chown root:root my.cnf \nshell> chmod 644 my.cnf<\/code><\/pre>\n
\n
my.cnf<\/code> \u540c\u4e00\u4f4d\u7f6e\u5b58\u5728\u5c5e\u4e8e\u53e6\u4e00\u4e2a MySQL \u5b9e\u4f8b\u7684\u73b0\u6709\u914d\u7f6e\u6587\u4ef6\uff0c\u8bf7\u4e3a\u60a8\u7684\u914d\u7f6e\u6587\u4ef6\u4f7f\u7528\u4e0d\u540c\u7684\u540d\u79f0\u3002<\/p>\n<\/blockquote>\n<\/li>\n
[mysqld]<\/code>\u7ec4\u6761\u76ee\u4e0b\uff0c\u4e3a\u5b9e\u4f8b\u8bbe\u7f6e
datadir<\/code><\/a>\u3001
socket<\/code><\/a>\u3001
port<\/code><\/a>\u3001
log-error<\/code><\/a>\u9009\u9879\u3002\u5982\u679c\u4e3b\u673a\u4e0a\u8fd8\u6709\u5176\u4ed6 MySQL \u5b89\u88c5\uff0c\u8bf7\u786e\u4fdd\u8fd9\u4e9b\u9009\u9879\u7684\u503c\u5bf9\u4e8e\u6b64\u5b9e\u4f8b\u662f\u552f\u4e00\u7684\u3002\u6b64\u90e8\u7f72\u4f7f\u7528\u9ed8\u8ba4\u503c\u3002<\/p>\n
[mysqld]\ndatadir=\/usr\/local\/mysql\/data\nsocket=\/usr\/local\/mysql\/mysql.sock\nport=3306\nlog-error=\/usr\/local\/mysql\/mysql.err.log<\/code><\/pre>\n
\n
\/usr\/local\/mysql\/data<\/code>)\uff0c\u5e76\u4e14\u5bf9\u76ee\u5f55\u7684\u8bbf\u95ee\u4ec5\u9650\u4e8e
mysql<\/code>\u64cd\u4f5c\u7cfb\u7edf\u7528\u6237\u5e10\u6237\u3002<\/p>\n<\/blockquote>\n<\/li>\n
user<\/code><\/a>\u9009\u9879\u4ee5\u786e\u4fdd\u670d\u52a1\u5668\u4ee5\u975e\u7279\u6743
mysql<\/code>\u7528\u6237\u5e10\u6237\u542f\u52a8 \u3002\u51fa\u4e8e\u5b89\u5168\u539f\u56e0\uff0c\u907f\u514d\u4ee5\u64cd\u4f5c\u7cfb\u7edf
root<\/code>\u7528\u6237\u8eab\u4efd\u8fd0\u884c\u670d\u52a1\u5668\u975e\u5e38\u91cd\u8981\u3002<\/p>\n
user=mysql<\/code><\/pre>\n<\/li>\n
secure_file_priv<\/code><\/a>\u7cfb\u7edf\u53d8\u91cf\u8bbe\u7f6e\u4e3a
mysql-files<\/code> \u60a8\u4e4b\u524d\u521b\u5efa\u7684\u76ee\u5f55\u7684\u8def\u5f84\u3002\u6b64\u9009\u9879\u5c06\u6587\u4ef6\u5bfc\u5165\u548c\u5bfc\u51fa\u64cd\u4f5c\uff08\u4f8b\u5982\u7531
LOAD DATA<\/code><\/a>and
SELECT ... INTO OUTFILE<\/code><\/a>\u8bed\u53e5\u548c
LOAD_FILE()<\/code><\/a>\u51fd\u6570\u6267\u884c\u7684\u64cd\u4f5c\uff09\u9650\u5236\u5230\u6307\u5b9a\u76ee\u5f55\u3002\u5982\u679c\u60a8\u4e0d\u6253\u7b97\u5141\u8bb8\u5bfc\u5165\u6216\u5bfc\u51fa\u64cd\u4f5c\uff0c\u8bf7\u8bbe\u7f6e
secure_file_priv<\/code><\/a>\u4e3a
NULL<\/code>\uff0c\u8fd9\u5c06\u5b8c\u5168\u7981\u7528\u5bfc\u5165\u548c\u5bfc\u51fa\u64cd\u4f5c\u3002
NULL<\/code>\u662f\u9ed8\u8ba4\u8bbe\u7f6e\u3002<\/p>\n
secure_file_priv=\/usr\/local\/mysql\/mysql-files<\/code><\/pre>\n<\/li>\n
LOCAL<\/code>\u7248\u672c\u7684 \u6f5c\u5728\u5b89\u5168\u95ee\u9898
LOAD DATA<\/code><\/a>\uff0c\u8bf7\u786e\u4fdd
local_infile<\/code><\/a>\u7981\u7528\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u3002<\/p>\n
local_infile=OFF<\/code><\/pre>\n
[mysqld]\ndatadir=\/usr\/local\/mysql\/data\nsocket=\/usr\/local\/mysql\/mysql.sock\nport=3306\nlog-error=\/usr\/local\/mysql\/mysql.err.log\nuser=mysql\nsecure_file_priv=\/usr\/local\/mysql\/mysql-files\nlocal_infile=OFF<\/code><\/pre>\n
\u521d\u59cb\u5316\u6570\u636e\u76ee\u5f55<\/h3>\n
mysql<\/code>\u7cfb\u7edf\u6570\u636e\u5e93\u53ca\u5176\u8868\uff0c\u5305\u62ec\u6388\u6743\u8868\u3001\u670d\u52a1\u5668\u7aef\u5e2e\u52a9\u8868\u548c\u65f6\u533a\u8868\u3002\u521d\u59cb\u5316\u8fd8\u4f1a\u521b\u5efa
root@localhost<\/code>\u8d85\u7ea7\u7528\u6237\u5e10\u6237\u548c
InnoDB<\/code>\u7ba1\u7406
InnoDB<\/code>\u8868\u6240\u9700\u7684 \u7cfb\u7edf\u8868\u7a7a\u95f4\u548c\u76f8\u5173\u6570\u636e\u7ed3\u6784\u3002<\/p>\n
\n
mysql<\/code>\u7528\u6237\u3002<\/p>\n
shell> cd \/usr\/local\/mysql\nshell> mkdir data\nshell> chmod 750 data\nshell> chown -R mysql:mysql \/usr\/local\/mysql<\/code><\/pre>\n
\n
mysql<\/code>\u7528\u6237\uff0c\u4f46\u5927\u90e8\u5206 MySQL \u5b89\u88c5\u4ecd\u7531
root<\/code>. \u5176\u4ed6\u4f8b\u5916\u662f\u9519\u8bef\u65e5\u5fd7\u6587\u4ef6\u3001
mysql-files<\/code>\u76ee\u5f55\u3001pid \u6587\u4ef6\u548c\u5957\u63a5\u5b57\u6587\u4ef6\uff0c
mysql<\/code> \u7528\u6237\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u6587\u4ef6\u5177\u6709\u5199\u8bbf\u95ee\u6743\u9650\u3002
mysql<\/code>\u7528\u6237\u9700\u8981\u8bfb\u53d6\u8bbf\u95ee\u6743\u9650\u4ee5\u5305\u62ec\u914d\u7f6e\u6587\u4ef6\uff08\u4f8b\u5982
\/etc\/my.cnf<\/code>\uff09\u548c MySQL \u4e8c\u8fdb\u5236\u6587\u4ef6 (
\/usr\/local\/mysql\/bin<\/code>) \u7684\u6587\u4ef6\u548c\u8d44\u6e90 \u3002<\/p>\n<\/blockquote>\n<\/li>\n
shell> cd \/usr\/local\/mysql\nshell> bin\/mysqld --defaults-file=\/etc\/my.cnf --initialize<\/code><\/pre>\n
\/usr\/local\/mysql\/mysql.err.log<\/code>) \u4e2d\uff0c\u5e76\u4e14\u7c7b\u4f3c\u4e8e\u4e0b\u9762\u663e\u793a\u7684\u8f93\u51fa\u3002\u8f93\u51fa\u5305\u62ec
root@localhost<\/code>\u5e10\u6237\u7684\u521d\u59cb\u968f\u673a\u5bc6\u7801 \u3002\u7a0d\u540e\u9700\u8981\u5bc6\u7801\u624d\u80fd\u91cd\u7f6e
root@localhost<\/code>\u5bc6\u7801\u3002<\/p>\n
<\/p>\n<\/li>\n<\/ol>\n
mysql<\/code>\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u65f6\u533a\u8868\uff0c \u4f46\u4e0d\u586b\u5145\u5b83\u4eec\u3002\u4e3a\u6b64\uff0c\u8bf7\u53c2\u9605 MySQL \u670d\u52a1\u5668\u65f6\u533a\u652f\u6301\u4e2d\u7684\u8bf4\u660e<\/a>\u3002<\/p>\n
\u4f7f\u7528 systemd \u542f\u52a8\u670d\u52a1\u5668<\/h3>\n
systemctl {start|stop|restart|status} mysqld<\/code><\/pre>\n
\n
mysqld.service<\/code>\u5e76\u653e\u7f6e\u5728
\/usr\/lib\/systemd\/system<\/code>.<\/p>\n
shell> cd \/usr\/lib\/systemd\/system\nshell> touch mysqld.service\nshell> chmod 644 mysqld.service<\/code><\/pre>\n
mysqld.service<\/code>\u6587\u4ef6\u4e2d\uff1a<\/p>\n
[Unit]\nDescription=MySQL Server\nDocumentation=man:mysqld(7)\nDocumentation=http:\/\/dev.mysql.com\/doc\/refman\/en\/using-systemd.html\nAfter=network.target\nAfter=syslog.target\n\n[Install]\nWantedBy=multi-user.target\n\n[Service]\nUser=mysql\nGroup=mysql\n\nType=simple\n\nPIDFile=\/usr\/local\/mysql\/data\/mysqld.pid\n\n# Disable service start and stop timeout logic of systemd for mysqld service.\nTimeoutSec=0\n\n# Start main service\nExecStart=\/usr\/local\/mysql\/bin\/mysqld --defaults-file=\/etc\/my.cnf --daemonize --pid-file=\/usr\/local\/mysql\/data\/mysqld.pid $MYSQLD_OPTS \n\n# Use this to switch malloc implementation\nEnvironmentFile=-\/etc\/sysconfig\/mysql\n\n# Sets open_files_limit\nLimitNOFILE = 5000\n\nRestart=on-failure\n\nRestartPreventExitStatus=1\n\nPrivateTmp=false<\/code><\/pre>\n<\/li>\n
tmpfiles<\/code>\u529f\u80fd\u6dfb\u52a0\u914d\u7f6e\u6587\u4ef6 \u3002\u8be5\u6587\u4ef6\u88ab\u547d\u540d
mysql.conf<\/code>\u5e76\u653e\u7f6e\u5728
\/usr\/lib\/tmpfiles.d<\/code>.<\/p>\n
shell> cd \/usr\/lib\/tmpfiles.d\nshell> touch mysql.conf\nshell> chmod 644 mysql.conf<\/code><\/pre>\n
mysql.conf<\/code>\u6587\u4ef6\u4e2d\uff1a<\/p>\n
d \/usr\/local\/mysql\/data 0750 mysql mysql -<\/code><\/pre>\n<\/li>\n
mysqld<\/code>\u670d\u52a1\u5728\u91cd\u65b0\u542f\u52a8\u65f6\u81ea\u52a8\u542f\u52a8\u3002<\/p>\n
shell> systemctl enable mysqld.service\nCreated symlink from \/etc\/systemd\/system\/multi-user.target.wants\/mysqld.service \nto \/usr\/lib\/systemd\/system\/mysqld.service.<\/code><\/pre>\n<\/li>\n
mysqld<\/code>\u4f7f\u7528systemctl<\/strong>\u624b\u52a8\u542f\u52a8 \u670d\u52a1 \u3002<\/p>\n
shell> systemctl start mysqld<\/code><\/pre>\n<\/li>\n
mysqld<\/code>\u670d\u52a1\u7684\u72b6\u6001\u3002\u8f93\u51fa\u5e94\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u5185\u5bb9\uff0c\u8fd9\u8868\u660emysqld<\/strong>\u670d\u52a1\u5df2\u6210\u529f\u542f\u52a8\u3002<\/p>\n
shell> systemctl status mysqld<\/code><\/pre>\n
<\/p>\n<\/li>\n
mysqld<\/code>\u518d\u6b21\u68c0\u67e5\u670d\u52a1\u72b6\u6001\u3002<\/p>\n
shell> systemctl status mysqld<\/code><\/pre>\n<\/li>\n
journalctl -u mysqld<\/code>. \u67d0\u4e9b\u6d88\u606f\uff0c\u4f8b\u5982 MySQL \u542f\u52a8\u6d88\u606f\uff0c\u53ef\u80fd\u4f1a\u6253\u5370\u5230 systemd \u65e5\u5fd7\u4e2d\u3002<\/p>\n<\/li>\n<\/ol>\n
\u91cd\u7f6e MySQL \u6839\u5e10\u6237\u5bc6\u7801<\/h3>\n
shell> systemctl status mysqld<\/code><\/pre>\n
root<\/code> \u5e10\u6237 (
root@localhost<\/code>)\u751f\u6210\u4e00\u4e2a\u968f\u673a\u521d\u59cb\u5bc6\u7801\u5e76\u6807\u8bb0\u4e3a\u5df2\u8fc7\u671f\u3002\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\u4ee5\u8bbe\u7f6e\u65b0\u5bc6\u7801\uff1a<\/p>\n
\n
mysql<\/code>\u5ba2\u6237\u7aef\uff0c
root@localhost<\/code>\u4f7f\u7528\u670d\u52a1\u5668\u5728\u521d\u59cb\u5316\u5e8f\u5217\u671f\u95f4\u751f\u6210\u7684\u968f\u673a\u5bc6\u7801\u8fde\u63a5\u5230\u670d\u52a1\u5668\uff1a<\/p>\n
shell> cd \/usr\/local\/mysql \nshell> bin\/mysql -u root -p\nEnter password: (enter the random root password here)<\/code><\/pre>\n<\/li>\n
root@localhost<\/code>\u5bc6\u7801\u3002\u4f7f\u7528\u5f3a\u5bc6\u7801\u3002\u7406\u60f3\u60c5\u51b5\u4e0b\uff0c\u5bc6\u7801\u5e94\u7b26\u5408\u60a8\u5c06\u4f7f\u7528\u8be5
validate_password<\/code>\u7ec4\u4ef6\u5b9a\u4e49\u7684\u5bc6\u7801\u7b56\u7565\uff0c\u8be5\u7ec4\u4ef6\u5c06 \u5728\u7a0d\u540e\u7684\u6b65\u9aa4\u4e2d\u542f\u7528\u3002\uff08\u8bf7\u53c2\u9605 \u7b2c 6 \u7ae0\uff0c\u5b89\u88c5 MySQL \u5bc6\u7801\u9a8c\u8bc1\u7ec4\u4ef6<\/em><\/a>\u3002\uff09<\/p>\n
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';<\/code><\/pre>\n
RANDOM PASSWORD<\/code>\u9009\u9879\u751f\u6210\u968f\u673a\u5bc6\u7801 \u3002\u6709\u5173\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 \u968f\u673a\u5bc6\u7801\u751f\u6210<\/a>\u3002<\/p>\n<\/li>\n<\/ol>\n
\u6d4b\u8bd5\u670d\u52a1\u5668<\/h3>\n
root<\/code>\u7528\u6237\u5bc6\u7801\u5df2\u91cd\u7f6e\uff0c\u8bf7\u6267\u884c\u51e0\u4e2a\u7b80\u5355\u7684\u6d4b\u8bd5\u4ee5\u9a8c\u8bc1\u670d\u52a1\u5668\u662f\u5426\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n