{"id":5146,"date":"2025-11-04T23:19:16","date_gmt":"2025-11-04T15:19:16","guid":{"rendered":"https:\/\/qaqaq.top\/?p=5146"},"modified":"2025-11-05T17:23:38","modified_gmt":"2025-11-05T09:23:38","slug":"ubuntu%e5%ae%89%e8%a3%85mysql%e8%b8%a9%e5%9d%91%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/qaqaq.top\/?p=5146","title":{"rendered":"Ubuntu\u5b89\u88c5MySQL\u8e29\u5751\u8bb0\u5f55"},"content":{"rendered":"\n<p>\u5b89\u88c5\u6559\u7a0b\u5982\u4e0b<\/p>\n\n\n\n<p><a href=\"https:\/\/www.modb.pro\/db\/1787599262368468992\">https:\/\/www.modb.pro\/db\/1787599262368468992<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8e29\u5751\u4e00\uff1atcp\u8fde\u63a5mysql\u6ca1\u95ee\u9898\uff0csocket\u8fde\u63a5mysql\u5931\u8d25<\/h2>\n\n\n\n<p>\u5168\u5c40\u641c\u7d22 mysql.sock<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo find \/ -type s -name \"*mysql*.sock\" 2&gt;\/dev\/null\n\nrichiezhang@computer:\/$ sudo find \/ -type s -name \"*mysql*.sock\" 2&gt;\/dev\/null\n\/tmp\/systemd-private-8e431245bb61421e8779371ae6fd1448-mysql.service-HljfC6\/tmp\/mysql.sock\n\/tmp\/systemd-private-8e431245bb61421e8779371ae6fd1448-mysql.service-HljfC6\/tmp\/mysqlx.sock<\/code><\/pre>\n\n\n\n<p>\u8fd9\u662f <strong>systemd \u7684\u79c1\u6709\u4e34\u65f6\u76ee\u5f55\uff08PrivateTmp\uff09\u673a\u5236<\/strong>\u5bfc\u81f4\u7684\uff0c\u5e38\u89c1\u4e8e <strong>Ubuntu\/Debian \u7b49\u4f7f\u7528 systemd \u7684\u7cfb\u7edf<\/strong>\u3002<\/p>\n\n\n\n<p>\u4ece <strong>systemd 235+ \u7248\u672c\u5f00\u59cb<\/strong>\uff0c\u8bb8\u591a\u670d\u52a1\uff08\u5305\u62ec <code>mysql.service<\/code>\uff09\u9ed8\u8ba4\u542f\u7528\u4e86\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PrivateTmp=true<\/code><\/pre>\n\n\n\n<p>\u8fd9\u610f\u5473\u7740\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u670d\u52a1\u7684 <code>\/tmp<\/code> \u76ee\u5f55\u662f<strong>\u9694\u79bb\u7684<\/strong>\uff0c\u5b9e\u9645\u6620\u5c04\u5230 <code>\/tmp\/systemd-private-&lt;hash&gt;-mysql.service-&lt;random&gt;\/tmp\/<\/code><\/li>\n\n\n\n<li><strong>\u5bbf\u4e3b\u673a\u76f4\u63a5\u8bbf\u95ee <code>\/tmp\/mysql.sock<\/code> \u662f\u627e\u4e0d\u5230\u7684<\/strong><\/li>\n\n\n\n<li>\u4f46 MySQL \u670d\u52a1\u5185\u90e8\u770b\u5230\u7684 socket \u8def\u5f84\u4ecd\u662f <code>\/tmp\/mysql.sock<\/code><\/li>\n<\/ul>\n\n\n\n<p>\u6240\u4ee5 <code>SHOW VARIABLES LIKE 'socket';<\/code> \u8fd4\u56de <code>\/tmp\/mysql.sock<\/code>\uff0c\u4f46\u4f60\u5728\u5bbf\u4e3b\u673a\u7684 <code>\/tmp<\/code> \u4e0b\u770b\u4e0d\u5230\u5b83\u3002<\/p>\n\n\n\n<p>\u89e3\u51b3\u65b9\u6848\uff0c\/etc\/systemd\/system\/mysql.service \u4e2d PrivateTmp=false<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Unit]\nDescription=MySQL Server\nAfter=network.target\n\n&#91;Service]\nType=notify\nUser=mysql\nGroup=mysql\nExecStart=\/usr\/local\/mysql-8.4.7\/bin\/mysqld --defaults-file=\/etc\/my.cnf\nRestart=always\nRestartSec=5\nTimeoutSec=300\nStandardOutput=null\nStandardError=journal\nLimitNOFILE=65536\n\n# \u5b89\u5168\u52a0\u56fa\uff08\u53ef\u9009\uff09\nPrivateTmp=false\nProtectHome=true\nNoNewPrivileges=true\n\n&#91;Install]\nWantedBy=multi-user.target\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u8e29\u5751\u4e8c\uff1amysql\u91cd\u590d\u542f\u52a8\uff0c\u62a5\u9519\u627e\u4e0d\u5230pid\u6587\u4ef6<\/h2>\n\n\n\n<p>\u539f\u56e0\u662f\u56e0\u4e3aubuntu\u6bcf\u6b21\u5f00\u673a\u4f1a\u81ea\u52a8\u5220\u9664\/var\/run\/mysqld\/\u76ee\u5f55<\/p>\n\n\n\n<p>\u89e3\u51b3\u65b9\u6848\uff0c\u66f4\u6539 \/etc\/my.cnf<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;mysqld]\ndatadir = \/usr\/local\/mysql-8.4.7\/data\nsocket = \/tmp\/mysql.sock\n\nlog-error = \/var\/log\/mysql\/mysqld.log\n\n#\u91cd\u542f\u540e\/var\/run\/mysqld\/\u76ee\u5f55\u4f1a\u6d88\u5931\uff0c\u6240\u4ee5\u6ce8\u91ca\n#pid-file = \/var\/run\/mysqld\/mysqld.pid\n\nbasedir = \/usr\/local\/mysql-8.4.7<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5\u6559\u7a0b\u5982\u4e0b https:\/\/www.modb.pro\/db\/1787599262368468992 \u8e29\u5751\u4e00\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":[91],"tags":[47],"class_list":["post-5146","post","type-post","status-publish","format-standard","hentry","category-mysql-","tag-mysql"],"_links":{"self":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/5146"}],"collection":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5146"}],"version-history":[{"count":3,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/5146\/revisions"}],"predecessor-version":[{"id":5164,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/5146\/revisions\/5164"}],"wp:attachment":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}