{"id":1481,"date":"2023-03-24T22:38:05","date_gmt":"2023-03-24T14:38:05","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1481"},"modified":"2023-04-28T20:32:09","modified_gmt":"2023-04-28T12:32:09","slug":"install-mysql-8-in-binary-mode-under-centos","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/24\/install-mysql-8-in-binary-mode-under-centos\/","title":{"rendered":"CentOS\u4e0b\u4ee5\u4e8c\u8fdb\u5236\u65b9\u5f0f\u5b89\u88c5 MySQL 8"},"content":{"rendered":"<h2>\u521b\u5efaMySQL\u7528\u6237\u548c\u76f8\u5173\u76ee\u5f55\uff08my.cnf\u8bbe\u7f6e\u7684\u76ee\u5f55\uff09<\/h2>\n<pre><code>groupadd mysql\nuseradd -g mysql -M -s \/bin\/nologin mysql\n\nmkdir \/usr\/local\/mysql    #mysql\u5b89\u88c5\u76ee\u5f55\nmkdir \/data\/mysqldb -p    #mysql\u6570\u636e\u76ee\u5f55\nmkdir -p \/data\/logs\/mysql\/binlog    #mysql\u4e8c\u8fdb\u5236\u65e5\u5fd7\u76ee\u5f55\nmkdir -p \/data\/logs\/mysql\/log    #mysql\u6162\u65e5\u5fd7\u3001\u9519\u8bef\u65e5\u5fd7\u3001\u666e\u901a\u65e5\u5fd7\u5b58\u653e\u76ee\u5f55\nmkdir -p \/data\/logs\/mysql\/mariadb\ntouch \/data\/logs\/mysql\/log\/mysql-error.log    #\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u9519\u8bef\u65e5\u5fd7\u8def\u5f84\u662f\u4ec0\u4e48\u5c31\u521b\u5efa\u4ec0\u4e48\u6587\u4ef6\ntouch \/data\/logs\/mysql\/mariadb\/mariadb.log\nmkdir -p \/opt\/mysqltmp    #mysql\u4e34\u65f6\u8868\u76ee\u5f55\nchown mysql:mysql \/usr\/local\/mysql -R\nchown mysql:mysql \/data\/mysqldb -R\nchown mysql:mysql \/data\/logs\/mysql -R\nchown mysql:mysql \/opt\/mysqltmp<\/code><\/pre>\n<p><!-- more --><\/p>\n<h2>\u5b89\u88c5MySQL 8.0<\/h2>\n<p>\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># wget http:\/\/mirrors.ustc.edu.cn\/mysql-ftp\/Downloads\/MySQL-8.0\/mysql-8.0.17-linux-glibc2.12-x86_64.tar\n# tar -xf mysql-8.0.17-linux-glibc2.12-x86_64.tar\n# ls -al mysql-*\n-rw-r--r-- 1 root root  665221120 Jun 27 18:05 mysql-8.0.17-linux-glibc2.12-x86_64.tar\n-rw-r--r-- 1 7155 31415 480209016 Jun 27 16:34 mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz\n-rw-r--r-- 1 7155 31415  34514636 Jun 27 17:42 mysql-router-8.0.17-linux-glibc2.12-x86_64.tar.xz\n-rw-r--r-- 1 7155 31415 150488620 Jun 27 18:05 mysql-test-8.0.17-linux-glibc2.12-x86_64.tar.xz\n# mv mysql-8.0.17-linux-glibc2.12-x86_64.tar mysql-8.0.17-linux-glibc2.12-x86_64-all.tar\n# xz -k -d mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz\n# tar -xf mysql-8.0.17-linux-glibc2.12-x86_64.tar\n# mv mysql-8.0.17-linux-glibc2.12-x86_64 \/usr\/local\/mysql<\/code><\/pre>\n<h2>\u670d\u52a1\u542f\u52a8\u811a\u672c<\/h2>\n<pre><code>cp \/usr\/local\/mysql\/support-files\/mysql.server \/etc\/init.d\/mysqld\nchmod 755 \/etc\/init.d\/mysqld<\/code><\/pre>\n<p>\u591a\u4e2amysql\u5b9e\u4f8b\u4e0d\u53ef\u80fd\u5171\u7528\u540c\u4e00\u4e2a\u5b89\u88c5\u76ee\u5f55\u548c\u6570\u636e\u5b58\u653e\u76ee\u5f55\uff0c\u6bcf\u4e2amysql\u5b9e\u4f8b\u90fd\u5e94\u6709\u81ea\u5df1\u5bf9\u5e94\u7684\u76ee\u5f55\uff0c\u591a\u5b9e\u4f8b\u9700\u8981\u4fee\u6539mysql\u670d\u52a1\u542f\u52a8\u811a\u672c\u4e2d\u7684\u76ee\u5f55\u4f4d\u7f6e\uff0c\u5982\u679c\u4e0d\u662f\u591a\u5b9e\u4f8b\u8fd9\u4e00\u6b65\u53ef\u514d<\/p>\n<pre><code>vim \/etc\/init.d\/mysqld\nbasedir=\/usr\/local\/mysql\ndatadir=\/data\/mysqldb<\/code><\/pre>\n<h2>\u914d\u7f6e\u6587\u4ef6\u3000<\/h2>\n<p>\u5728MySQL\u6570\u636e\u5e93\u4e2d\uff0c\u53ef\u4ee5\u6ca1\u6709\u914d\u7f6e\u6587\u4ef6\uff0c\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cMySQL\u4f1a\u4ee5\u5b89\u88c5\u7f16\u8bd1\u65f6\u7684\u9ed8\u8ba4\u53c2\u6570\u8bbe\u7f6e\u542f\u52a8\u5b9e\u4f8b\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5f53MYSQL\u6570\u636e\u5e93\u5b9e\u4f8b\u542f\u52a8\u65f6\uff0c\u4f1a\u5728\u54ea\u4e9b\u4f4d\u7f6e\u67e5\u627e\u914d\u7f6e\u6587\u4ef6<\/p>\n<pre><code># \/usr\/local\/mysql\/bin\/mysql --help | grep my.cn\n    order of preference, my.cnf, $MYSQL_TCP_PORT,\n\/etc\/my.cnf \/etc\/mysql\/my.cnf \/usr\/local\/mysql\/etc\/my.cnf ~\/.my.cnf<\/code><\/pre>\n<pre><code># mkdir \/usr\/local\/mysql\/etc\n# vim \/usr\/local\/mysql\/etc\/my.cnf<\/code><\/pre>\n<p>MySQL\u91cc\u9762\u6709\u542f\u52a8\u53c2\u6570\u3001\u7cfb\u7edf\u53c2\u6570\uff0c\u542f\u52a8\u53c2\u6570\u901a\u8fc7show variables\u65e0\u6cd5\u67e5\u8be2\u5230\uff0c\u53ef\u4ee5\u5728mysqld\u7684\u9009\u9879\u4e2d\u67e5\u5230\uff0c\u4f8b\u5982\u5173\u4e8e\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6709Startup Options Used with Binary Logging\u3001System Variables Used with Binary Logging\u4e24\u79cd\u53c2\u6570<\/p>\n<p>\u914d\u7f6e\u6587\u4ef6my.cnf\u8be6\u89e3\uff1a<\/p>\n<pre><code>[client]\nport = 3306      #\u5ba2\u6237\u7aef\u6240\u8fde\u63a5\u7684\u7aef\u53e3\u53f7\nsocket = \/tmp\/mysql.sock      #\u5ba2\u6237\u7aef\u6240\u8fde\u63a5\u7684sock\u6587\u4ef6\u5b58\u653e\u4f4d\u7f6e\n\n[mysqld]\n#base\nport = 3306      #mysql\u7684\u9ed8\u8ba4\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u4fee\u6539\nuser = mysql      #mysql\u7528\u6237\u6307\u5b9a\nsocket = \/tmp\/mysql.sock      #\u8fde\u63a5\u6240\u4f7f\u7528\u7684\u7aef\u53e3\u53f7\npid-file = \/var\/run\/mysql\/mysql.pid      #\u8fdb\u7a0b\u8fd0\u884c\u7684\u4e3bPID\u6587\u4ef6\nbasedir = \/usr\/local\/mysql      #Mysql\u5b89\u88c5\u76ee\u5f55\ndatadir = \/data\/mysqldb      #Mysql\u6570\u636e\u76ee\u5f55\ntmpdir = \/opt\/mysqltmp      #Mysql\u4e34\u65f6\u8868\u76ee\u5f55\nopen_files_limit = 10240      #\u6253\u5f00\u6587\u4ef6\u53e5\u67c4\u7684\u6570\u91cf\nexplicit_defaults_for_timestamp \nsql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES\nfederated      #\u652f\u6301sql\u8bed\u6cd5\u548c\u6570\u636e\u6821\u9a8c\u7b49.sql_mode\u4e09\u79cd\u6a21\u5f0f \n\n#ANSI\u6a21\u5f0f\u3001\u5bbd\u677e\u6a21\u5f0f\uff0c\u5bf9\u63d2\u5165\u6570\u636e\u8fdb\u884c\u6821\u9a8c\uff0c\u5982\u679c\u4e0d\u7b26\u5408\u5b9a\u4e49\u7c7b\u578b\u6216\u957f\u5ea6\uff0c\u5bf9\u6570\u636e\u7c7b\u578b\u8c03\u6574\u6216\u8005\u622a\u65ad\u4fdd\u5b58\uff0c\u62a5\u201cwarning\u201d\u8b66\u544a\n#TRADITIONAL\u6a21\u5f0f\u3001\u4e25\u683c\u6a21\u5f0f\uff0c\u5f53\u5411mysql\u6570\u636e\u63d2\u5165\u6570\u636e\u65f6\u3001\u8fdb\u884c\u6570\u636e\u7684\u4e25\u683c\u6821\u9a8c\uff0c\u4fdd\u8bc1\u6570\u636e\u4e0d\u80fd\u63d2\u5165\uff0c\u62a5error\u9519\u8bef\uff0c\u7528\u4e8e\u4e8b\u7269\u65f6\uff0c\u4f1a\u8fdb\u884c\u4e8b\u7269\u56de\u6eda\n#STRICT_TRANS_TABLES\u6a21\u5f0f\u3002\u4e25\u683c\u6a21\u5f0f\uff0c\u8fdb\u884c\u6570\u636e\u7684\u4e25\u683c\u6821\u9a8c\uff0c\u9519\u8bef\u6570\u636e\u4e0d\u80fd\u63d2\u5165\uff0c\u62a5error\u9519\u8bef\n\ndefault_authentication_plugin = mysql_native_password      #MySQL 8\u9ed8\u8ba4\u4f7f\u7528\u65b0\u7684\u5bc6\u7801\u9a8c\u8bc1\u63d2\u4ef6\uff1acaching_sha2_password\uff0c\u65e9\u671f\u7684PHP\u7248\u672c\u4e2d\u6240\u5e26\u7684mysqlnd\u65e0\u6cd5\u652f\u6301\u8fd9\u79cd\u9a8c\u8bc1\n\nserver_id = 706      #\u4e3b\u4ece\u590d\u5236\u552f\u4e00\u7684\u670d\u52a1\u8fa8\u8bc6\u53f7\uff0c\u6570\u503c\u4f4d\u4e8e 1 \u5230\n#replicate-do-db = posp      #\u5b9a\u4e49\u552f\u4e00\u590d\u5236\u7684\u5e93\n#replicate-ignore-db = mysql      #\u5b9a\u4e49\u552f\u4e00\u590d\u5236\u7684\u5e93\n#log-slave-updates = 1      #\u8be5\u9009\u9879\u53ea\u518d\u4e3b\u4ece\u590d\u5236\uff0c\u4ece\u670d\u52a1\u5668\u4e0a\u6253\u5f00\u590d\u5236\u4e3b\u7684\u4fe1\u606f\nevent_scheduler=1      #\u6253\u5f00\u65f6\u95f4\u8c03\u5ea6\u5668\n\nmax_connections = 2000      #\u6700\u5927\u5e76\u53d1\u8fde\u63a5\u6570 \uff0c\u589e\u5927\u8be5\u503c\u9700\u8981\u76f8\u5e94\u589e\u52a0\u5141\u8bb8\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u6570\nmax_connect_errors = 10000      #\u5982\u679c\u67d0\u4e2a\u7528\u6237\u53d1\u8d77\u7684\u8fde\u63a5error\u8d85\u8fc7\u8be5\u6570\u503c\uff0c\u5219\u8be5\u7528\u6237\u7684\u4e0b\u6b21\u8fde\u63a5\u5c06\u88ab\u963b\u585e\ninteractive_timeout = 600      #\u670d\u52a1\u5668\u5173\u95ed\u4ea4\u4e92\u8fde\u63a5\u524d\u7b49\u5f85\u6d3b\u52a8\u7684\u79d2\u6570\nwait_timeout = 600      #\u670d\u52a1\u5668\u5173\u95ed\u975e\u4ea4\u4e92\u8fde\u63a5\u4e4b\u524d\u7b49\u5f85\u6d3b\u52a8\u7684\u79d2\u6570\nskip-name-resolve      #garnt\u65f6\uff0c\u5fc5\u987b\u4f7f\u7528ip\uff0c\u4e0d\u80fd\u4f7f\u7528\u4e3b\u673a\u540d\uff0c\u7981\u7528DNS\u89e3\u6790\nsync_binlog = 0      #\u53ef\u4ee5\u4fdd\u8bc1\u4e8b\u52a1\u7684\u5b89\u5168\u3002\u7f3a\u7701\u4e3a0\nlog_bin_trust_function_creators = 1      #\u6253\u5f00mysql\u53ef\u81ea\u5b9a\u4e49\u51fd\u6570\n\ncharacter-set-server = utf8      #\u8bbe\u5b9a\u5b57\u7b26\u96c6\ndefault_storage_engine = InnoDB      #\u5b9a\u4e49\u9ed8\u8ba4\u5f15\u64ce\n\n#log\nlog-bin = \/data\/logs\/mysql\/binlog\/mysql-bin      #\u6307\u5b9abinlog\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u6587\u4ef6\u540d\u79f0\nbinlog_cache_size = 32m      #binlog\u7684\u7f13\u5b58\u5927\u5c0f\nmax_binlog_cache_size = 10g      #\u8bbe\u5b9a\u6700\u5927\u7684binlog\u7f13\u5b58\nbinlog_stmt_cache_size = 32m      #\u8bbe\u5b9a\u6700\u5c0f\u7684binlo\u7f13\u5b58\ntable_open_cache = 2048      #\u8868\u63cf\u8ff0\u7b26\u7f13\u5b58\u5927\u5c0f\uff0c\u53ef\u51cf\u5c11\u6587\u4ef6\u6253\u5f00\/\u5173\u95ed\u6b21\u6570\nmax_binlog_size = 1024m      #\u8bbe\u7f6ebinlog\u65e5\u5fd7\u6587\u4ef6\u6700\u5927\u4e3a1G\nbinlog_format = mixed      #binlog\u65e5\u5fd7\u683c\u5f0f.\nlog_output = FILE      #\u786e\u8ba4\u8f93\u51fa\u5230\u65e5\u5fd7\u6587\u4ef6\nlog-error = \/data\/logs\/mysql\/log\/mysql-error.log      #mysql\u7cfb\u7edf\u9519\u8bef\u65e5\u5fd7\u8f93\u51fa\nslow_query_log = 1      #\u6253\u5f00\u6162\u65e5\u5fd7\u8bb0\u5f55\nslow_query_log_file = \/data\/logs\/mysql\/log\/mysql-slow_query.log      #\u5b9a\u4e49\u6162\u65e5\u5fd7\u8f93\u51fa\u7684\u8def\u5f84\ngeneral_log = 0      #\u5b9a\u4e49\u666e\u901a\u65e5\u5fd7\ngeneral_log_file = \/data\/logs\/mysql\/log\/mysql-general-query.log      #\u5b9a\u4e49\u666e\u901a\u65e5\u5fd7\u8f93\u51fa\u7684\u8def\u5f84\nexpire-logs-days = 30      #\u65e5\u5fd7\u4fdd\u7559\u7684\u65f6\u95f4\u4e3a30\u5929\nrelay-log = \/data\/logs\/mysql\/binlog\/relay-bin      #\u5b9a\u4e49reloa_log\u590d\u5236\u7684\u5730\u5740\nrelay-log-index= \/data\/logs\/mysql\/binlog\/relay-bin.index      #\u5b9a\u4e49reloa_log\u7d22\u5f15\n\n#buffer\nsort_buffer_size = 2m      #MyISAM\u8868\u53d1\u751f\u53d8\u5316\u65f6\u91cd\u65b0\u6392\u5e8f\u6240\u9700\u7684\u7f13\u51b2\u3002\u4e00\u822c64M\u8db3\u77e3\nread_buffer_size = 2m      #\u7528\u6765\u505aMyISAM\u8868\u5168\u8868\u626b\u63cf\u7684\u7f13\u51b2\u5927\u5c0f.\nread_rnd_buffer_size = 2m      #\u5f53\u5728\u6392\u5e8f\u4e4b\u540e,\u4ece\u4e00\u4e2a\u5df2\u7ecf\u6392\u5e8f\u597d\u7684\u5e8f\u5217\u4e2d\u8bfb\u53d6\u884c\u65f6,\u884c\u6570\u636e\u5c06\u4ece\u8fd9\u4e2a\u7f13\u51b2\u4e2d\u8bfb\u53d6\u6765\u9632\u6b62\u78c1\u76d8\u5bfb\u9053\njoin_buffer_size = 2m      #InnoDB\u7528\u6765\u7f13\u5b58\u6570\u636e\u548c\n\nnet_buffer_length = 16k      #\u6267\u884cmysqldump\u65f6\uff0cnet buffer length\u7684\u6700\u5927\u4e0a\u9650\u662f16Mb\uff0c\u9ed8\u8ba4\u503c\u662f1Mb\nmax_allowed_packet = 512m      #\u6bcf\u4e2a\u8fde\u63a5\u72ec\u7acb\u7684\u5927\u5c0f.\u5927\u5c0f\u52a8\u6001\u589e\u52a0 \nbulk_insert_buffer_size = 32m      #\u5f53\u7a81\u53d1\u63d2\u5165\u88ab\u68c0\u6d4b\u5230\u65f6\u6b64\u7f13\u51b2\u5c06\u88ab\u5206\u914d\u7528\u4e8emyisam\nmax_heap_table_size = 512m      #\u5185\u5b58\u8868\u7684\u5927\u5c0f\ntmp_table_size = 512m      #\u5185\u90e8(\u5185\u5b58\u4e2d)\u4e34\u65f6\u8868\u7684\u6700\u5927\u5927\u5c0f \nthread_cache_size = 100      #\u7f13\u5b58\u53ef\u91cd\u7528\u7684\u7ebf\u7a0b\u6570\uff0c\u53ef\u4ee5\u9002\u5f53\u7684\u8c03\u6574\n#query_cache_size = 256m      #\u6307\u5b9aMySQL\u67e5\u8be2\u7ed3\u679c\u7f13\u51b2\u533a\u7684\u5927\u5c0f\u3002\u8c03\u4f18\u53ef\u4ee5\u9002\u5f53\u8c03\u6574\uff08\u5df2\u8fc7\u65f6\uff09\n#query_cache_limit = 10m      #\u7f13\u5b58\u5355\u6761SQL\u7684\u7ed3\u679c\u96c6\u4e0a\u9650\uff0c\u9ed8\u8ba44KB\u3002\u8c03\u4f18\u53ef\u4ee5\u9002\u5f53\u8c03\u6574\uff08\u5df2\u8fc7\u65f6\uff09\n#query_cache_min_res_unit = 4k\nkey_buffer_size = 16m      #\u5173\u952e\u8bcd\u7f13\u51b2\u7684\u5927\u5c0f, \u4e00\u822c\u7528\u6765\u7f13\u51b2MyISAM\u8868\u7684\u7d22\u5f15\u5757\nmyisam_sort_buffer_size = 64m      #\u8fd9\u5728\u6bcf\u4e2a\u7ebf\u7a0b\u4e2d\u88ab\u5206\u914d.\u6240\u4ee5\u5728\u8bbe\u7f6e\u5927\u503c\u65f6\u9700\u8981\u5c0f\u5fc3\nmyisam_max_sort_file_size = 10g      #MySQL\u91cd\u5efa\u7d22\u5f15\u65f6\u6240\u5141\u8bb8\u7684\u6700\u5927\u4e34\u65f6\u6587\u4ef6\u7684\u5927\u5c0f\u5982\u679c\u6587\u4ef6\u5927\u5c0f\u6bd4\u6b64\u503c\u66f4\u5927\uff0c\u7d22\u5f15\u4f1a\u901a\u8fc7\u952e\u503c\u7f13\u51b2\u521b\u5efa(\u66f4\u6162)\nmyisam_repair_threads = 1      #\u5982\u679c\u4e00\u4e2a\u8868\u62e5\u6709\u8d85\u8fc7\u4e00\u4e2a\u7d22\u5f15\uff0cMyISAM \n\n#innodb\ninnodb_file_per_table = 1      #\u53ef\u4ee5\u4fee\u6539InnoDB\u4e3a\u72ec\u7acb\u8868\u7a7a\u95f4\u6a21\u5f0f,\u6bcf\u4e2a\u6570\u636e\u5e93\u7684\u6bcf\u4e2a\u8868\u90fd\u4f1a\u751f\u6210\u4e00\u4e2a\u6570\u636e\u7a7a\u95f4\ninnodb_data_file_path = ibdata1:2048M:autoextend      #\u5982\u679c\u4f60\u53ea\u6709\u5355\u4e2a\u903b\u8f91\u9a71\u52a8\u4fdd\u5b58\u4f60\u7684\u6570\u636e\uff0c\u4e00\u4e2a\u5355\u4e2a\u7684\u81ea\u589e\u6587\u4ef6\u5c31\u8db3\u591f\u597d\ninnodb_log_file_size = 128m      #\u5728\u65e5\u5fd7\u7ec4\u4e2d\u6bcf\u4e2a\u65e5\u5fd7\u6587\u4ef6\u7684\u5927\u5c0f\ninnodb_log_files_in_group = 3      #\u5728\u65e5\u5fd7\u7ec4\u4e2d\u7684\u6587\u4ef6\u603b\u6570\u3002\u901a\u5e38\u6765\u8bf42~3\u662f\u6bd4\u8f83\u597d\u7684\ninnodb_buffer_pool_size = 1g      #innodb\u7f13\u5b58\u6c60\u5927\u5c0f\ninnodb_buffer_pool_instances = -1\ninnodb_max_dirty_pages_pct = 70      #\u5728InnoDB\u7f13\u51b2\u6c60\u4e2d\u6700\u5927\u5141\u8bb8\u7684\u810f\u9875\u9762\u7684\u6bd4\u4f8b\uff0c60-90\u90fd\u53ef\u4ee5\n#innodb_thread_concurrency = 8\ninnodb_flush_method = O_DIRECT\ninnodb_log_buffer_size = 16m      #\u7528\u6765\u7f13\u51b2\u65e5\u5fd7\u6570\u636e\u7684\u7f13\u51b2\u533a\u7684\u5927\u5c0f\u3002\u5f53\u6b64\u503c\u5feb\u6ee1\u65f6\uff0cInnoDB\u5c06\u5fc5\u987b\u5237\u65b0\u6570\u636e\u5230\u78c1\u76d8\u4e0a\ninnodb_flush_log_at_trx_commit = 2\n\n#0\u4ee3\u8868\u65e5\u5fd7\u53ea\u5927\u7ea6\u6bcf\u79d2\u5199\u5165\u65e5\u5fd7\u6587\u4ef6\u5e76\u4e14\u65e5\u5fd7\u6587\u4ef6\u5237\u65b0\u5230\u78c1\u76d8\n#2\u4ee3\u8868\u65e5\u5fd7\u5199\u5165\u65e5\u5fd7\u6587\u4ef6\u5728\u6bcf\u6b21\u63d0\u4ea4\u540e\uff0c\u4f46\u662f\u65e5\u5fd7\u6587\u4ef6\u53ea\u6709\u5927\u7ea6\u6bcf\u79d2\u624d\u4f1a\u5237\u65b0\u5230\u78c1\u76d8\u4e0a\n\n[mysqld_safe]\nlog-error=\/data\/logs\/mysql\/mariadb\/mariadb.log\npid-file=\/var\/run\/mariadb\/mariadb.pid\n\n[mysql]\nno-auto-rehash      #\u53ef\u4ee5\u5728\u547d\u4ee4\u53ef\u4ee5\u4f7f\u7528tab\u952e\u8865\u9f50\nprompt = (\\u@\\h) [\\d]\\_      #\u5728Mysql\u547d\u4ee4\u663e\u793a\u4e3b\u673a\u540d\u5b57\ndefault-character-set = utf8      #\u8bbe\u5b9a\u5b57\u7b26\u96c6\u5408\n\n[client]\nsocket=\/tmp\/mysql.sock<\/code><\/pre>\n<h2>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/h2>\n<pre><code># vim \/etc\/profile\n\nMYSQL=\/usr\/local\/mysql\/bin\nPATH=$PATH:$MYSQL\nexport PATH\n\n# source \/etc\/profile  \/\/\u4f7f\u914d\u7f6e\u751f\u6548<\/code><\/pre>\n<pre><code># mysql -V\nmysql  Ver 8.0.17 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)<\/code><\/pre>\n<h2>\u521d\u59cb\u5316<\/h2>\n<pre><code>\/usr\/local\/mysql\/scprit\/mysql_install_db --user=mysql --basedir=\/usr\/local\/mysql --datadir=\/data\/mysqldb<\/code><\/pre>\n<pre><code>\/usr\/local\/mysql\/bin\/mysqld --initialize --user=mysql --basedir=\/usr\/local\/mysql --datadir=\/data\/mysqldb<\/code><\/pre>\n<p>\u67e5\u770broot\u5bc6\u7801\uff1a<\/p>\n<pre><code># grep &quot;password&quot; vim \/data\/logs\/mysql\/log\/mysql-error.log\ngrep: vim: No such file or directory\n\/data\/logs\/mysql\/log\/mysql-error.log:2019-07-31T12:48:22.524067Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: sQYxsCRCk6&gt;F<\/code><\/pre>\n<h2>\u542f\u52a8\u670d\u52a1<\/h2>\n<pre><code>\/etc\/init.d\/mysqld start<\/code><\/pre>\n<h2>\u6d4b\u8bd5MySQL\u8fde\u63a5<\/h2>\n<pre><code># mysql -uroot -p\nEnter password: \nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 8\nServer version: 8.0.17\n\nCopyright (c) 2000, 2019, Oracle and\/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType &#039;help;&#039; or &#039;\\h&#039; for help. Type &#039;\\c&#039; to clear the current input statement.\n\n(root@localhost) [(none)] show databases;\nERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.\n(root@localhost) [(none)] alter user &#039;root&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;appblog@2019&#039;;  \/\/alter user &#039;root&#039;@&#039;%&#039; IDENTIFIED BY &#039;appblog@2019&#039;;\nQuery OK, 0 rows affected (0.01 sec)\n\n(root@localhost) [(none)] flush privileges;\nQuery OK, 0 rows affected (0.00 sec)\n\n(root@localhost) [(none)] show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| information_schema |\n| mysql              |\n| performance_schema |\n| sys                |\n+--------------------+\n4 rows in set (0.17 sec)\n\n(root@localhost) [(none)] <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u521b\u5efaMySQL\u7528\u6237\u548c\u76f8\u5173\u76ee\u5f55\uff08my.cnf\u8bbe\u7f6e\u7684\u76ee\u5f55\uff09 groupadd mysql useradd -g m [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[333],"tags":[20],"class_list":["post-1481","post","type-post","status-publish","format-standard","hentry","category-install-deploy","tag-mysql"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1481","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=1481"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1481\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}