{"id":60245,"date":"2026-01-15T10:05:31","date_gmt":"2026-01-15T02:05:31","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/60245.html"},"modified":"2026-01-15T10:05:31","modified_gmt":"2026-01-15T02:05:31","slug":"mcp-cherry-studio-%e5%ae%9e%e6%88%98%ef%bc%9amysql-mcp-%e6%9c%8d%e5%8a%a1%e6%90%ad%e5%bb%ba%e4%b8%8e%e5%ba%94%e7%94%a8%e6%9c%ac%e5%9c%b0%e9%83%a8%e7%bd%b2","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/60245.html","title":{"rendered":"MCP + Cherry Studio \u5b9e\u6218\uff1aMySQL MCP \u670d\u52a1\u642d\u5efa\u4e0e\u5e94\u7528(\u672c\u5730\u90e8\u7f72)"},"content":{"rendered":"<h3>\u4e00\u3001\u672c\u5730\u90e8\u7f72\u6838\u5fc3\u4f18\u52bf<\/h3>\n<li>\u6570\u636e\u96f6\u6cc4\u9732&#xff1a;\u6570\u636e\u5e93\u548c MCP \u670d\u52a1\u5747\u8fd0\u884c\u5728\u672c\u5730&#xff0c;\u65e0\u9700\u66b4\u9732\u516c\u7f51&#xff0c;\u7b26\u5408\u4f01\u4e1a\u5185\u7f51\u5b89\u5168\u8981\u6c42&#xff1b;<\/li>\n<li>\u65e0\u7f51\u7edc\u4f9d\u8d56&#xff1a;\u65ad\u7f51\u73af\u5883\u4e0b\u4ecd\u53ef\u6b63\u5e38\u8c03\u7528 MySQL MCP \u670d\u52a1&#xff1b;<\/li>\n<li>\u8c03\u8bd5\u66f4\u9ad8\u6548&#xff1a;\u672c\u5730\u65e5\u5fd7\u5b9e\u65f6\u67e5\u770b&#xff0c;\u95ee\u9898\u5b9a\u4f4d\u66f4\u5feb&#xff1b;<\/li>\n<li>\u9002\u914d\u6240\u6709\u7cfb\u7edf&#xff1a;Windows\/Mac\/Linux \u64cd\u4f5c\u6b65\u9aa4\u7edf\u4e00&#xff0c;\u4ec5\u8def\u5f84\u683c\u5f0f\u7565\u6709\u5dee\u5f02\u3002<\/li>\n<hr \/>\n<h3>\u4e8c\u3001\u672c\u5730\u73af\u5883\u524d\u7f6e\u68c0\u67e5<\/h3>\n<h4>2.1 \u5fc5\u88c5\u5de5\u5177&#xff08;\u672c\u5730\u5df2\u6709\u7684\u53ef\u8df3\u8fc7&#xff09;<\/h4>\n<table>\n<tr>\u5de5\u5177\u68c0\u67e5\u65b9\u5f0f\u5feb\u901f\u5b89\u88c5\u5efa\u8bae<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">MySQL&#xff08;\u672c\u5730&#xff09;<\/td>\n<td align=\"left\">\u7ec8\u7aef\u6267\u884c mysql -u root -p \u80fd\u767b\u5f55<\/td>\n<td align=\"left\">Windows&#xff1a;\u5b89\u88c5 XAMPP\/WAMP&#xff1b;Mac&#xff1a;brew install mysql&#xff1b;Linux&#xff1a;apt install mysql-server<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">Python 3.10&#043;<\/td>\n<td align=\"left\">\u7ec8\u7aef\u6267\u884c python &#8211;version<\/td>\n<td align=\"left\">\u5b98\u7f51\u4e0b\u8f7d&#xff1a;https:\/\/www.python.org\/downloads\/<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">Cherry Studio<\/td>\n<td align=\"left\">\u80fd\u6b63\u5e38\u542f\u52a8\u5ba2\u6237\u7aef<\/td>\n<td align=\"left\">\u5b98\u7f51\u4e0b\u8f7d&#xff1a;https:\/\/cherry-ai.com\/<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">pip\/uv<\/td>\n<td align=\"left\">\u7ec8\u7aef\u6267\u884c pip &#8211;version \u6216 uv &#8211;version<\/td>\n<td align=\"left\">python -m ensurepip &#8211;upgrade&#xff08;pip&#xff09;&#xff1b;pip install uv&#xff08;uv&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2.2 \u672c\u5730 MySQL \u57fa\u7840\u914d\u7f6e&#xff08;\u5173\u952e&#xff01;&#xff09;<\/h4>\n<h5>1. \u786e\u8ba4\u672c\u5730 MySQL \u8fd0\u884c\u72b6\u6001<\/h5>\n<ul>\n<li>Windows&#xff1a;\u6253\u5f00\u670d\u52a1\u9762\u677f&#xff0c;\u786e\u8ba4\u300cMySQL\u300d\u670d\u52a1\u72b6\u6001\u4e3a\u300c\u6b63\u5728\u8fd0\u884c\u300d&#xff1b;<\/li>\n<li>Mac&#xff1a;brew services list \u67e5\u770b mysql \u72b6\u6001&#xff0c;\u672a\u8fd0\u884c\u5219\u6267\u884c brew services start mysql&#xff1b;<\/li>\n<li>Linux&#xff1a;systemctl status mysql&#xff0c;\u672a\u8fd0\u884c\u5219\u6267\u884c systemctl start mysql\u3002<\/li>\n<\/ul>\n<h5>2. \u521b\u5efa\u672c\u5730\u6d4b\u8bd5\u5e93\/\u8868&#xff08;\u907f\u514d\u64cd\u4f5c\u751f\u4ea7\u6570\u636e&#xff09;<\/h5>\n<p>\u767b\u5f55\u672c\u5730 MySQL \u6267\u884c\u4ee5\u4e0b SQL&#xff08;\u5bc6\u7801\u4e3a\u4f60\u7684\u672c\u5730 MySQL root \u5bc6\u7801&#xff09;&#xff1a;<\/p>\n<p><span class=\"token comment\">&#8212; \u767b\u5f55\u672c\u5730 MySQL<\/span><br \/>\nmysql <span class=\"token operator\">&#8211;<\/span>u root <span class=\"token operator\">&#8211;<\/span>p<\/p>\n<p><span class=\"token comment\">&#8212; 1. \u521b\u5efa\u4ec5\u672c\u5730\u4f7f\u7528\u7684\u6d4b\u8bd5\u5e93<\/span><br \/>\n<span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">DATABASE<\/span> <span class=\"token keyword\">IF<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token keyword\">EXISTS<\/span> local_mcp_mysql<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">USE<\/span> local_mcp_mysql<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; 2. \u521b\u5efa\u6d4b\u8bd5\u8868&#xff08;\u4ee5\u8ba2\u5355\u8868\u4e3a\u4f8b&#xff0c;\u9002\u914d\u63a5\u53e3\u6d4b\u8bd5\u573a\u666f&#xff09;<\/span><br \/>\n<span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> <span class=\"token keyword\">IF<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token keyword\">EXISTS<\/span> test_order <span class=\"token punctuation\">(<\/span><br \/>\n    order_id <span class=\"token keyword\">INT<\/span> <span class=\"token keyword\">AUTO_INCREMENT<\/span> <span class=\"token keyword\">PRIMARY<\/span> <span class=\"token keyword\">KEY<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    order_no <span class=\"token keyword\">VARCHAR<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">32<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">UNIQUE<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token boolean\">NULL<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    user_id <span class=\"token keyword\">INT<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token boolean\">NULL<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    amount <span class=\"token keyword\">DECIMAL<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token boolean\">NULL<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    create_time <span class=\"token keyword\">DATETIME<\/span> <span class=\"token keyword\">DEFAULT<\/span> <span class=\"token keyword\">CURRENT_TIMESTAMP<\/span><br \/>\n<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">ENGINE<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token keyword\">InnoDB<\/span> <span class=\"token keyword\">DEFAULT<\/span> <span class=\"token keyword\">CHARSET<\/span><span class=\"token operator\">&#061;<\/span>utf8mb4<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; 3. \u63d2\u5165\u672c\u5730\u6d4b\u8bd5\u6570\u636e<\/span><br \/>\n<span class=\"token keyword\">INSERT<\/span> <span class=\"token keyword\">INTO<\/span> test_order <span class=\"token punctuation\">(<\/span>order_no<span class=\"token punctuation\">,<\/span> user_id<span class=\"token punctuation\">,<\/span> amount<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">VALUES<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;LOCAL_MCP_001&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1001<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">99.90<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;LOCAL_MCP_002&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1002<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">199.90<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; 4. \u6388\u6743\u672c\u5730\u8d26\u53f7&#xff08;\u4ec5\u5141\u8bb8 127.0.0.1\/localhost \u8bbf\u95ee&#xff0c;\u675c\u7edd\u5916\u90e8\u8fde\u63a5&#xff09;<\/span><br \/>\n<span class=\"token keyword\">GRANT<\/span> <span class=\"token keyword\">ALL<\/span> <span class=\"token keyword\">PRIVILEGES<\/span> <span class=\"token keyword\">ON<\/span> local_mcp_mysql<span class=\"token punctuation\">.<\/span><span class=\"token operator\">*<\/span> <span class=\"token keyword\">TO<\/span> <span class=\"token string\">&#039;root&#039;<\/span><span class=\"token variable\">&#064;&#039;localhost&#039;<\/span> IDENTIFIED <span class=\"token keyword\">BY<\/span> <span class=\"token string\">&#039;\u4f60\u7684\u672c\u5730MySQL\u5bc6\u7801&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\nFLUSH <span class=\"token keyword\">PRIVILEGES<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<hr \/>\n<h3>\u4e09\u3001\u672c\u5730 MySQL MCP \u670d\u52a1\u642d\u5efa&#xff08;\u6838\u5fc3\u6b65\u9aa4&#xff09;<\/h3>\n<h4>3.1 \u672c\u5730\u521b\u5efa MCP \u670d\u52a1\u76ee\u5f55&#xff08;\u7edf\u4e00\u8def\u5f84&#xff0c;\u907f\u514d\u6df7\u4e71&#xff09;<\/h4>\n<h5>Windows \u793a\u4f8b&#xff08;\u5efa\u8bae&#xff09;&#xff1a;<\/h5>\n<p><span class=\"token comment\"># \u6253\u5f00 cmd \u7ec8\u7aef&#xff0c;\u521b\u5efa\u76ee\u5f55<\/span><br \/>\n<span class=\"token function\">mkdir<\/span> D:<span class=\"token punctuation\">\\\\<\/span>local_mcp<span class=\"token punctuation\">\\\\<\/span>mysql_mcp<br \/>\n<span class=\"token builtin class-name\">cd<\/span> D:<span class=\"token punctuation\">\\\\<\/span>local_mcp<span class=\"token punctuation\">\\\\<\/span>mysql_mcp<\/p>\n<h5>Mac\/Linux \u793a\u4f8b&#xff1a;<\/h5>\n<p><span class=\"token function\">mkdir<\/span> -p ~\/local_mcp\/mysql_mcp<br \/>\n<span class=\"token builtin class-name\">cd<\/span> ~\/local_mcp\/mysql_mcp<\/p>\n<h4>3.2 \u5b89\u88c5\u672c\u5730 MySQL MCP \u4f9d\u8d56&#xff08;\u865a\u62df\u73af\u5883\u9694\u79bb&#xff09;<\/h4>\n<p><span class=\"token comment\"># 1. \u521b\u5efa\u672c\u5730\u865a\u62df\u73af\u5883&#xff08;\u4ec5\u672c\u5730\u4f7f\u7528&#xff0c;\u907f\u514d\u6c61\u67d3\u5168\u5c40\u4f9d\u8d56&#xff09;<\/span><br \/>\nuv venv local_mysql_env<\/p>\n<p><span class=\"token comment\"># 2. \u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/span><br \/>\n<span class=\"token comment\"># Windows<\/span><br \/>\nlocal_mysql_env<span class=\"token punctuation\">\\\\<\/span>Scripts<span class=\"token punctuation\">\\\\<\/span>activate<br \/>\n<span class=\"token comment\"># Mac\/Linux<\/span><br \/>\n<span class=\"token builtin class-name\">source<\/span> local_mysql_env\/bin\/activate<\/p>\n<p><span class=\"token comment\"># 3. \u5b89\u88c5\u672c\u5730 MySQL MCP \u6838\u5fc3\u5305&#xff08;\u9002\u914d\u672c\u5730\u6570\u636e\u5e93&#xff09;<\/span><br \/>\nuv pip <span class=\"token function\">install<\/span> mcp-mysql python-dotenv pymysql<\/p>\n<h4>3.3 \u7f16\u5199\u672c\u5730 MySQL MCP \u670d\u52a1\u811a\u672c&#xff08;\u4ec5\u672c\u5730\u8fde\u63a5&#xff09;<\/h4>\n<p>\u5728 mysql_mcp \u76ee\u5f55\u4e0b\u521b\u5efa local_mysql_mcp.py&#xff08;\u6838\u5fc3\u811a\u672c&#xff0c;\u4ec5\u8fde\u63a5\u672c\u5730 MySQL&#xff09;&#xff1a;<\/p>\n<p><span class=\"token comment\"># local_mysql_mcp.py<\/span><br \/>\n<span class=\"token keyword\">import<\/span> os<br \/>\n<span class=\"token keyword\">import<\/span> sys<br \/>\n<span class=\"token keyword\">from<\/span> dotenv <span class=\"token keyword\">import<\/span> load_dotenv<br \/>\n<span class=\"token keyword\">from<\/span> mcp_mysql <span class=\"token keyword\">import<\/span> MySQLMCP<br \/>\n<span class=\"token keyword\">import<\/span> pymysql<\/p>\n<p><span class=\"token comment\"># \u52a0\u8f7d\u672c\u5730\u73af\u5883\u53d8\u91cf&#xff08;\u4ec5\u672c\u5730\u8bfb\u53d6&#xff0c;\u4e0d\u5bf9\u5916\u66b4\u9732&#xff09;<\/span><br \/>\nload_dotenv<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u672c\u5730 MySQL \u8fde\u63a5\u914d\u7f6e&#xff08;\u56fa\u5b9a\u672c\u5730\u5730\u5740&#xff0c;\u7981\u6b62\u516c\u7f51\u8bbf\u95ee&#xff09;<\/span><br \/>\nLOCAL_MYSQL_CONFIG <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string\">&#034;host&#034;<\/span><span class=\"token punctuation\">:<\/span> os<span class=\"token punctuation\">.<\/span>getenv<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;MYSQL_HOST&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;127.0.0.1&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span>  <span class=\"token comment\"># \u5f3a\u5236\u672c\u5730\u5730\u5740&#xff0c;\u7981\u6b62\u4fee\u6539\u4e3a0.0.0.0<\/span><br \/>\n    <span class=\"token string\">&#034;port&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">int<\/span><span class=\"token punctuation\">(<\/span>os<span class=\"token punctuation\">.<\/span>getenv<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;MYSQL_PORT&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">3306<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token string\">&#034;user&#034;<\/span><span class=\"token punctuation\">:<\/span> os<span class=\"token punctuation\">.<\/span>getenv<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;MYSQL_USER&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;root&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token string\">&#034;password&#034;<\/span><span class=\"token punctuation\">:<\/span> os<span class=\"token punctuation\">.<\/span>getenv<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;MYSQL_PASSWORD&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span>  <span class=\"token comment\"># \u672c\u5730MySQL\u5bc6\u7801<\/span><br \/>\n    <span class=\"token string\">&#034;database&#034;<\/span><span class=\"token punctuation\">:<\/span> os<span class=\"token punctuation\">.<\/span>getenv<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;MYSQL_DB&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;local_mcp_mysql&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span>  <span class=\"token comment\"># \u672c\u5730\u6d4b\u8bd5\u5e93<\/span><br \/>\n    <span class=\"token string\">&#034;charset&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;utf8mb4&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token string\">&#034;connect_timeout&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">5<\/span><span class=\"token punctuation\">,<\/span>  <span class=\"token comment\"># \u672c\u5730\u8fde\u63a5\u8d85\u65f6&#xff08;\u77ed\u4e00\u70b9&#xff0c;\u5feb\u901f\u5931\u8d25&#xff09;<\/span><br \/>\n    <span class=\"token string\">&#034;local_infile&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token boolean\">True<\/span>   <span class=\"token comment\"># \u542f\u7528\u672c\u5730\u6587\u4ef6\u5bfc\u5165&#xff08;\u4ec5\u672c\u5730\u4f7f\u7528&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u672c\u5730\u8fde\u63a5\u6d4b\u8bd5&#xff08;\u542f\u52a8\u524d\u6821\u9a8c&#xff09;<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">test_local_mysql_conn<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        conn <span class=\"token operator\">&#061;<\/span> pymysql<span class=\"token punctuation\">.<\/span>connect<span class=\"token punctuation\">(<\/span><span class=\"token operator\">**<\/span>LOCAL_MYSQL_CONFIG<span class=\"token punctuation\">)<\/span><br \/>\n        cursor <span class=\"token operator\">&#061;<\/span> conn<span class=\"token punctuation\">.<\/span>cursor<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        cursor<span class=\"token punctuation\">.<\/span>execute<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;SELECT 1&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;[\u672c\u5730\u6d4b\u8bd5] MySQL \u8fde\u63a5\u6210\u529f&#xff01;&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        conn<span class=\"token punctuation\">.<\/span>close<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">True<\/span><br \/>\n    <span class=\"token keyword\">except<\/span> Exception <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;[\u672c\u5730\u6d4b\u8bd5] MySQL \u8fde\u63a5\u5931\u8d25&#xff1a;<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token builtin\">str<\/span><span class=\"token punctuation\">(<\/span>e<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n        sys<span class=\"token punctuation\">.<\/span>exit<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u542f\u52a8\u672c\u5730 MySQL MCP \u670d\u52a1&#xff08;\u4ec5 STDIO \u534f\u8bae&#xff0c;\u9002\u914d Cherry Studio \u672c\u5730\u8c03\u7528&#xff09;<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">start_local_mysql_mcp<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token comment\"># \u5148\u6821\u9a8c\u672c\u5730\u8fde\u63a5<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token keyword\">not<\/span> test_local_mysql_conn<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span><\/p>\n<p>    <span class=\"token comment\"># \u521d\u59cb\u5316\u672c\u5730 MCP \u670d\u52a1<\/span><br \/>\n    mcp <span class=\"token operator\">&#061;<\/span> MySQLMCP<span class=\"token punctuation\">(<\/span>config<span class=\"token operator\">&#061;<\/span>LOCAL_MYSQL_CONFIG<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;[\u542f\u52a8\u6210\u529f] \u672c\u5730 MySQL MCP \u670d\u52a1\u5df2\u542f\u52a8&#xff08;\u4ec5\u672c\u5730\u8bbf\u95ee&#xff09;&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token comment\"># \u8fd0\u884c STDIO \u670d\u52a1&#xff08;Cherry Studio \u672c\u5730\u8c03\u7528\u7684\u6838\u5fc3\u534f\u8bae&#xff09;<\/span><br \/>\n    mcp<span class=\"token punctuation\">.<\/span>run_stdio<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">if<\/span> __name__ <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token string\">&#034;__main__&#034;<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token comment\"># \u5f3a\u5236\u9650\u5b9a\u4ec5\u672c\u5730\u8fd0\u884c&#xff0c;\u7981\u6b62\u8fdc\u7a0b\u8bbf\u95ee<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> LOCAL_MYSQL_CONFIG<span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;host&#034;<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token keyword\">not<\/span> <span class=\"token keyword\">in<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;127.0.0.1&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;localhost&#034;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;[\u9519\u8bef] \u672c\u5730 MCP \u670d\u52a1\u4ec5\u5141\u8bb8\u8fde\u63a5 127.0.0.1\/localhost&#xff01;&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        sys<span class=\"token punctuation\">.<\/span>exit<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    start_local_mysql_mcp<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h4>3.4 \u521b\u5efa\u672c\u5730\u73af\u5883\u53d8\u91cf\u6587\u4ef6&#xff08;.env&#xff09;<\/h4>\n<p>\u5728\u540c\u76ee\u5f55\u4e0b\u521b\u5efa .env \u6587\u4ef6&#xff08;\u586b\u5199\u672c\u5730 MySQL \u4fe1\u606f&#xff0c;\u4ec5\u672c\u5730\u53ef\u89c1&#xff09;&#xff1a;<\/p>\n<p># \u672c\u5730 MySQL \u914d\u7f6e&#xff08;\u4ec5\u672c\u5730\u4f7f\u7528&#xff0c;\u8bf7\u52ff\u63d0\u4ea4\u5230\u4efb\u4f55\u4ed3\u5e93&#xff09;<br \/>\nMYSQL_HOST&#061;127.0.0.1<br \/>\nMYSQL_PORT&#061;3306<br \/>\nMYSQL_USER&#061;root<br \/>\nMYSQL_PASSWORD&#061;\u4f60\u7684\u672c\u5730MySQL\u5bc6\u7801  # \u5982&#xff1a;123456 \u6216\u7a7a&#xff08;\u65e0\u5bc6\u7801\u65f6\u586b&#034;&#034;&#xff09;<br \/>\nMYSQL_DB&#061;local_mcp_mysql<\/p>\n<h4>3.5 \u672c\u5730\u6d4b\u8bd5 MCP \u670d\u52a1\u542f\u52a8<\/h4>\n<p><span class=\"token comment\"># \u786e\u4fdd\u5df2\u6fc0\u6d3b\u865a\u62df\u73af\u5883&#xff0c;\u6267\u884c\u811a\u672c<\/span><br \/>\npython local_mysql_mcp.py<\/p>\n<p>\u2705 \u6210\u529f\u63d0\u793a&#xff1a;<br \/>\n[\u672c\u5730\u6d4b\u8bd5] MySQL \u8fde\u63a5\u6210\u529f&#xff01;<br \/>\n[\u542f\u52a8\u6210\u529f] \u672c\u5730 MySQL MCP \u670d\u52a1\u5df2\u542f\u52a8&#xff08;\u4ec5\u672c\u5730\u8bbf\u95ee&#xff09;<br \/>\n\u274c \u5931\u8d25\u6392\u67e5&#xff1a;<\/p>\n<ul>\n<li>\u63d0\u793a\u5bc6\u7801\u9519\u8bef&#xff1a;\u6838\u5bf9 .env \u4e2d\u7684 MYSQL_PASSWORD&#xff1b;<\/li>\n<li>\u63d0\u793a\u6570\u636e\u5e93\u4e0d\u5b58\u5728&#xff1a;\u91cd\u65b0\u6267\u884c 2.2 \u8282\u7684\u5efa\u5e93 SQL&#xff1b;<\/li>\n<li>\u63d0\u793a\u8fde\u63a5\u62d2\u7edd&#xff1a;\u786e\u8ba4\u672c\u5730 MySQL \u670d\u52a1\u5df2\u542f\u52a8\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>\u56db\u3001Cherry Studio \u5bf9\u63a5\u672c\u5730 MySQL MCP \u670d\u52a1<\/h3>\n<h4>4.1 \u914d\u7f6e\u672c\u5730 MCP \u670d\u52a1&#xff08;\u5173\u952e&#xff01;&#xff09;<\/h4>\n<li>\u542f\u52a8 Cherry Studio&#xff08;\u672c\u5730\u5ba2\u6237\u7aef&#xff09;&#xff0c;\u8fdb\u5165\u300c\u8bbe\u7f6e \u2192 MCP \u670d\u52a1\u5668 \u2192 \u6dfb\u52a0 MCP \u670d\u52a1\u5668\u300d&#xff1b;<\/li>\n<li>\u586b\u5199\u7eaf\u672c\u5730\u914d\u7f6e&#xff08;\u7edd\u5bf9\u8def\u5f84\u5fc5\u987b\u51c6\u786e&#xff09;&#xff1a;<\/li>\n<table>\n<tr>\u914d\u7f6e\u9879\u586b\u5199\u503c&#xff08;\u793a\u4f8b&#xff09;\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">\u540d\u79f0<\/td>\n<td align=\"left\">Local-MySQL-MCP<\/td>\n<td align=\"left\">\u81ea\u5b9a\u4e49&#xff0c;\u4fbf\u4e8e\u8bc6\u522b<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u7c7b\u578b<\/td>\n<td align=\"left\">STDIO<\/td>\n<td align=\"left\">\u672c\u5730\u8c03\u7528\u9996\u9009\u534f\u8bae&#xff0c;\u65e0\u9700\u7aef\u53e3\/\u7f51\u7edc<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u547d\u4ee4<\/td>\n<td align=\"left\">python D:\\\\local_mcp\\\\mysql_mcp\\\\local_mysql_mcp.py<\/td>\n<td align=\"left\">Windows \u7edd\u5bf9\u8def\u5f84&#xff08;\u66ff\u6362\u4e3a\u4f60\u7684\u5b9e\u9645\u8def\u5f84&#xff09;Mac\/Linux&#xff1a;\/Users\/xxx\/local_mcp\/mysql_mcp\/local_mysql_mcp.py<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u5de5\u4f5c\u76ee\u5f55<\/td>\n<td align=\"left\">D:\\\\local_mcp\\\\mysql_mcp<\/td>\n<td align=\"left\">\u811a\u672c\u6240\u5728\u76ee\u5f55&#xff08;\u4e0e\u547d\u4ee4\u8def\u5f84\u4e00\u81f4&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u73af\u5883\u53d8\u91cf&#xff08;\u53ef\u9009&#xff09;<\/td>\n<td align=\"left\">\u65e0\u9700\u586b\u5199<\/td>\n<td align=\"left\">\u5df2\u901a\u8fc7 .env \u6587\u4ef6\u914d\u7f6e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<li>\u70b9\u51fb\u300c\u6d4b\u8bd5\u8fde\u63a5\u300d&#xff0c;\u63d0\u793a\u300c\u8fde\u63a5\u6210\u529f\u300d\u540e\u4fdd\u5b58&#xff0c;\u5e76\u5f00\u542f\u670d\u52a1&#xff08;\u5f00\u5173\u53d8\u7eff&#xff09;\u3002<\/li>\n<h4>4.2 \u672c\u5730\u8c03\u7528 MySQL MCP \u5b9e\u6218&#xff08;\u81ea\u7136\u8bed\u8a00\u64cd\u4f5c&#xff09;<\/h4>\n<p>\u5728 Cherry Studio \u5bf9\u8bdd\u9875\u8f93\u5165\u4ee5\u4e0b\u6307\u4ee4&#xff08;\u7eaf\u672c\u5730\u6267\u884c&#xff0c;\u65e0\u7f51\u7edc\u4f9d\u8d56&#xff09;&#xff1a;<\/p>\n<p>\u4f60\u662f\u672c\u5730\u6570\u636e\u5e93\u7ba1\u7406\u5458&#xff0c;\u4ec5\u901a\u8fc7 Local-MySQL-MCP \u670d\u52a1\u64cd\u4f5c\u672c\u5730\u6570\u636e\u5e93&#xff0c;\u6b65\u9aa4&#xff1a;<br \/>\n1. \u67e5\u8be2 local_mcp_mysql \u5e93\u4e2d test_order \u8868\u7684\u6240\u6709\u6570\u636e&#xff1b;<br \/>\n2. \u65b0\u589e\u4e00\u6761\u6d4b\u8bd5\u8ba2\u5355&#xff1a;order_no&#061;&#039;LOCAL_MCP_003&#039;, user_id&#061;1003, amount&#061;299.90&#xff1b;<br \/>\n3. \u518d\u6b21\u67e5\u8be2 test_order \u8868&#xff0c;\u786e\u8ba4\u65b0\u589e\u6570\u636e\u5b58\u5728&#xff1b;<br \/>\n4. \u7edf\u8ba1 test_order \u8868\u7684\u603b\u8ba2\u5355\u6570\u548c\u603b\u91d1\u989d&#xff1b;<br \/>\n5. \u8f93\u51fa\u6240\u6709\u64cd\u4f5c\u7684 SQL \u8bed\u53e5\u548c\u6267\u884c\u7ed3\u679c&#xff08;\u4ec5\u5c55\u793a&#xff0c;\u65e0\u9700\u8ba9\u6211\u624b\u52a8\u6267\u884c&#xff09;\u3002<\/p>\n<h5>\u2705 \u672c\u5730\u6267\u884c\u7ed3\u679c\u793a\u4f8b&#xff1a;<\/h5>\n<p>### 1. \u67e5\u8be2\u6240\u6709\u8ba2\u5355\u6570\u636e<br \/>\n\u6267\u884c SQL&#xff1a;SELECT * FROM test_order;<br \/>\n\u7ed3\u679c&#xff1a;<br \/>\n&#043;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;<br \/>\n| order_id | order_no    | user_id | amount | create_time         |<br \/>\n&#043;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;<br \/>\n| 1        | LOCAL_MCP_001 | 1001    | 99.90  | 2026-01-15 15:00:00 |<br \/>\n| 2        | LOCAL_MCP_002 | 1002    | 199.90 | 2026-01-15 15:00:00 |<br \/>\n&#043;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;<\/p>\n<p>### 2. \u65b0\u589e\u6d4b\u8bd5\u8ba2\u5355<br \/>\n\u6267\u884c SQL&#xff1a;INSERT INTO test_order (order_no, user_id, amount) VALUES (&#039;LOCAL_MCP_003&#039;, 1003, 299.90);<br \/>\n\u7ed3\u679c&#xff1a;\u6210\u529f\u63d2\u5165 1 \u6761\u6570\u636e<\/p>\n<p>### 3. \u9a8c\u8bc1\u65b0\u589e\u6570\u636e<br \/>\n\u6267\u884c SQL&#xff1a;SELECT * FROM test_order WHERE order_no&#061;&#039;LOCAL_MCP_003&#039;;<br \/>\n\u7ed3\u679c&#xff1a;\u5b58\u5728\u8be5\u8ba2\u5355&#xff0c;\u6570\u636e\u6b63\u786e<\/p>\n<p>### 4. \u7edf\u8ba1\u6570\u636e<br \/>\n\u6267\u884c SQL&#xff1a;SELECT COUNT(*) AS total_count, SUM(amount) AS total_amount FROM test_order;<br \/>\n\u7ed3\u679c&#xff1a;\u603b\u8ba2\u5355\u6570&#061;3&#xff0c;\u603b\u91d1\u989d&#061;599.70 \u5143<\/p>\n<p>### \u603b\u7ed3&#xff1a;\u6240\u6709\u672c\u5730\u6570\u636e\u5e93\u64cd\u4f5c\u6267\u884c\u6210\u529f&#xff08;\u7eaf\u672c\u5730\u8fd0\u884c&#xff0c;\u65e0\u516c\u7f51\u8bbf\u95ee&#xff09;<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u672c\u5730\u90e8\u7f72\u907f\u5751\u6307\u5357&#xff08;\u7eaf\u672c\u5730\u4e13\u5c5e&#xff09;<\/h3>\n<table>\n<tr>\u95ee\u9898\u73b0\u8c61\u672c\u5730\u4e13\u5c5e\u539f\u56e0\u89e3\u51b3\u65b9\u6848<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">Cherry \u63d0\u793a\u201c\u627e\u4e0d\u5230 Python \u89e3\u91ca\u5668\u201d<\/td>\n<td align=\"left\">Windows \u672a\u914d\u7f6e Python \u73af\u5883\u53d8\u91cf&#xff0c;\u6216\u865a\u62df\u73af\u5883\u672a\u6fc0\u6d3b<\/td>\n<td align=\"left\">1. \u5c06 Python \u5b89\u88c5\u8def\u5f84&#xff08;\u5982 C:\\\\Python310&#xff09;\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf&#xff1b;2. \u547d\u4ee4\u4e2d\u4f7f\u7528\u865a\u62df\u73af\u5883\u7684 Python \u7edd\u5bf9\u8def\u5f84&#xff1a;D:\\\\local_mcp\\\\mysql_mcp\\\\local_mysql_env\\\\Scripts\\\\python.exe<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">MCP \u670d\u52a1\u542f\u52a8\u540e\u7acb\u5373\u9000\u51fa<\/td>\n<td align=\"left\">\u672c\u5730 MySQL \u5bc6\u7801\u4e3a\u7a7a&#xff0c;\u4f46 .env \u4e2d\u586b\u4e86\u7a7a\u5b57\u7b26\u4e32<\/td>\n<td align=\"left\">1. \u5c06 .env \u4e2d MYSQL_PASSWORD&#061; \u7559\u7a7a&#xff08;\u4e0d\u52a0\u5f15\u53f7&#xff09;&#xff1b;2. \u6216\u7ed9\u672c\u5730 MySQL \u8bbe\u7f6e\u5bc6\u7801&#xff1a;ALTER USER &#039;root&#039;&#064;&#039;localhost&#039; IDENTIFIED BY &#039;\u65b0\u5bc6\u7801&#039;;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">Mac\/Linux \u63d0\u793a\u201cPermission denied\u201d<\/td>\n<td align=\"left\">\u811a\u672c\u65e0\u6267\u884c\u6743\u9650<\/td>\n<td align=\"left\">\u6267\u884c chmod &#043;x ~\/local_mcp\/mysql_mcp\/local_mysql_mcp.py<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u4e2d\u6587\u4e71\u7801&#xff08;\u672c\u5730\u67e5\u8be2&#xff09;<\/td>\n<td align=\"left\">\u672c\u5730 MySQL \u5b57\u7b26\u96c6\u4e0d\u662f utf8mb4<\/td>\n<td align=\"left\">1. \u6267\u884c ALTER DATABASE local_mcp_mysql CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;&#xff1b;2. \u91cd\u542f\u672c\u5730 MySQL \u670d\u52a1<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">Cherry \u8fde\u63a5 MCP \u8d85\u65f6&#xff08;Windows&#xff09;<\/td>\n<td align=\"left\">\u6740\u6bd2\u8f6f\u4ef6\u62e6\u622a\u4e86\u672c\u5730 STDIO \u901a\u4fe1<\/td>\n<td align=\"left\">\u4e34\u65f6\u5173\u95ed\u6740\u6bd2\u8f6f\u4ef6&#xff0c;\u6216\u5c06 Cherry Studio \u548c Python \u52a0\u5165\u767d\u540d\u5355<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u516d\u3001\u672c\u5730 MCP \u670d\u52a1\u4f18\u5316&#xff08;\u4fbf\u6377\u4f7f\u7528&#xff09;<\/h3>\n<h4>6.1 \u672c\u5730\u4e00\u952e\u542f\u52a8\u811a\u672c&#xff08;Windows \u6279\u5904\u7406&#xff09;<\/h4>\n<p>\u521b\u5efa start_local_mysql_mcp.bat&#xff08;\u53cc\u51fb\u5373\u53ef\u542f\u52a8&#xff0c;\u65e0\u9700\u624b\u52a8\u8f93\u547d\u4ee4&#xff09;&#xff1a;<\/p>\n<p>&#064;echo off<br \/>\necho \u6fc0\u6d3b\u672c\u5730\u865a\u62df\u73af\u5883&#8230;<br \/>\nD:\\\\local_mcp\\\\mysql_mcp\\\\local_mysql_env\\\\Scripts\\\\activate.bat<br \/>\necho \u542f\u52a8\u672c\u5730 MySQL MCP \u670d\u52a1&#8230;<br \/>\npython D:\\\\local_mcp\\\\mysql_mcp\\\\local_mysql_mcp.py<br \/>\npause<\/p>\n<h4>6.2 Mac\/Linux \u4e00\u952e\u542f\u52a8\u811a\u672c<\/h4>\n<p>\u521b\u5efa start_local_mysql_mcp.sh&#xff1a;<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u6fc0\u6d3b\u672c\u5730\u865a\u62df\u73af\u5883&#8230;&#034;<\/span><br \/>\n<span class=\"token builtin class-name\">source<\/span> ~\/local_mcp\/mysql_mcp\/local_mysql_env\/bin\/activate<br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u542f\u52a8\u672c\u5730 MySQL MCP \u670d\u52a1&#8230;&#034;<\/span><br \/>\npython ~\/local_mcp\/mysql_mcp\/local_mysql_mcp.py<\/p>\n<p>\u6388\u6743\u5e76\u8fd0\u884c&#xff1a;<\/p>\n<p><span class=\"token function\">chmod<\/span> &#043;x start_local_mysql_mcp.sh<br \/>\n.\/start_local_mysql_mcp.sh<\/p>\n<h4>6.3 \u672c\u5730\u65e5\u5fd7\u8bb0\u5f55&#xff08;\u4fbf\u4e8e\u8c03\u8bd5&#xff09;<\/h4>\n<p>\u4fee\u6539 local_mysql_mcp.py&#xff0c;\u6dfb\u52a0\u672c\u5730\u65e5\u5fd7&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u65b0\u589e\u65e5\u5fd7\u914d\u7f6e&#xff08;\u4ec5\u672c\u5730\u4fdd\u5b58&#xff09;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> logging<br \/>\nlogging<span class=\"token punctuation\">.<\/span>basicConfig<span class=\"token punctuation\">(<\/span><br \/>\n    filename<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;.\/local_mysql_mcp.log&#039;<\/span><span class=\"token punctuation\">,<\/span>  <span class=\"token comment\"># \u65e5\u5fd7\u6587\u4ef6\u4fdd\u5b58\u5728\u672c\u5730\u76ee\u5f55<\/span><br \/>\n    level<span class=\"token operator\">&#061;<\/span>logging<span class=\"token punctuation\">.<\/span>INFO<span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token builtin\">format<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;%(asctime)s &#8211; %(levelname)s &#8211; %(message)s&#039;<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u5728 test_local_mysql_conn \u4e2d\u6dfb\u52a0\u65e5\u5fd7<\/span><br \/>\nlogging<span class=\"token punctuation\">.<\/span>info<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u672c\u5730 MySQL \u8fde\u63a5\u6d4b\u8bd5\u5f00\u59cb&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\"># \u5728 start_local_mysql_mcp \u4e2d\u6dfb\u52a0\u65e5\u5fd7<\/span><br \/>\nlogging<span class=\"token punctuation\">.<\/span>info<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u672c\u5730 MySQL MCP \u670d\u52a1\u542f\u52a8\u6210\u529f&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<hr \/>\n<h3>\u4e03\u3001\u603b\u7ed3&#xff08;\u672c\u5730\u90e8\u7f72\u6838\u5fc3\u8981\u70b9&#xff09;<\/h3>\n<li>\u6838\u5fc3\u914d\u7f6e&#xff1a;\u672c\u5730 MySQL MCP \u670d\u52a1\u5f3a\u5236\u7ed1\u5b9a 127.0.0.1&#xff0c;\u675c\u7edd\u516c\u7f51\u8bbf\u95ee&#xff0c;\u4fdd\u969c\u6570\u636e\u5b89\u5168&#xff1b;<\/li>\n<li>\u534f\u8bae\u9009\u62e9&#xff1a;\u4f18\u5148\u4f7f\u7528 STDIO \u534f\u8bae&#xff0c;\u65e0\u9700\u914d\u7f6e\u7aef\u53e3\u3001\u9632\u706b\u5899&#xff0c;\u7eaf\u672c\u5730\u8fdb\u7a0b\u901a\u4fe1&#xff0c;\u7a33\u5b9a\u6027\u6700\u9ad8&#xff1b;<\/li>\n<li>\u4f9d\u8d56\u9694\u79bb&#xff1a;\u901a\u8fc7\u865a\u62df\u73af\u5883\u5b89\u88c5 MCP \u4f9d\u8d56&#xff0c;\u907f\u514d\u4e0e\u672c\u5730\u5176\u4ed6 Python \u9879\u76ee\u51b2\u7a81&#xff1b;<\/li>\n<li>\u4fbf\u6377\u4f7f\u7528&#xff1a;\u4e00\u952e\u542f\u52a8\u811a\u672c\u66ff\u4ee3\u624b\u52a8\u547d\u4ee4&#xff0c;\u964d\u4f4e\u672c\u5730\u4f7f\u7528\u6210\u672c\u3002<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u672c\u5730\u90e8\u7f72\u6838\u5fc3\u4f18\u52bf<br \/>\n\u6570\u636e\u96f6\u6cc4\u9732&#xff1a;\u6570\u636e\u5e93\u548c MCP \u670d\u52a1\u5747\u8fd0\u884c\u5728\u672c\u5730&#xff0c;\u65e0\u9700\u66b4\u9732\u516c\u7f51&#xff0c;\u7b26\u5408\u4f01\u4e1a\u5185\u7f51\u5b89\u5168\u8981\u6c42&#xff1b;\u65e0\u7f51\u7edc\u4f9d\u8d56&#xff1a;\u65ad\u7f51\u73af\u5883\u4e0b\u4ecd\u53ef\u6b63\u5e38\u8c03\u7528 MySQL MCP \u670d\u52a1&#xff1b;\u8c03\u8bd5\u66f4\u9ad8\u6548&#xff1a;\u672c\u5730\u65e5\u5fd7\u5b9e\u65f6\u67e5\u770b&#xff0c;\u95ee\u9898\u5b9a\u4f4d\u66f4\u5feb&#xff1b;\u9002\u914d\u6240\u6709\u7cfb\u7edf&#xff1a;Windows\/Mac\/Linux \u64cd\u4f5c\u6b65\u9aa4\u7edf\u4e00&#xff0c;\u4ec5\u8def\u5f84\u683c\u5f0f\u7565\u6709\u5dee\u5f02\u3002\u4e8c\u3001\u672c\u5730\u73af\u5883\u524d\u7f6e\u68c0\u67e5<br \/>\n2.1 <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[114,100],"topic":[],"class_list":["post-60245","post","type-post","status-publish","format-standard","hentry","category-server","tag-mysql","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MCP + Cherry Studio \u5b9e\u6218\uff1aMySQL MCP \u670d\u52a1\u642d\u5efa\u4e0e\u5e94\u7528(\u672c\u5730\u90e8\u7f72) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/60245.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MCP + Cherry Studio \u5b9e\u6218\uff1aMySQL MCP \u670d\u52a1\u642d\u5efa\u4e0e\u5e94\u7528(\u672c\u5730\u90e8\u7f72) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u672c\u5730\u90e8\u7f72\u6838\u5fc3\u4f18\u52bf \u6570\u636e\u96f6\u6cc4\u9732&#xff1a;\u6570\u636e\u5e93\u548c MCP \u670d\u52a1\u5747\u8fd0\u884c\u5728\u672c\u5730&#xff0c;\u65e0\u9700\u66b4\u9732\u516c\u7f51&#xff0c;\u7b26\u5408\u4f01\u4e1a\u5185\u7f51\u5b89\u5168\u8981\u6c42&#xff1b;\u65e0\u7f51\u7edc\u4f9d\u8d56&#xff1a;\u65ad\u7f51\u73af\u5883\u4e0b\u4ecd\u53ef\u6b63\u5e38\u8c03\u7528 MySQL MCP \u670d\u52a1&#xff1b;\u8c03\u8bd5\u66f4\u9ad8\u6548&#xff1a;\u672c\u5730\u65e5\u5fd7\u5b9e\u65f6\u67e5\u770b&#xff0c;\u95ee\u9898\u5b9a\u4f4d\u66f4\u5feb&#xff1b;\u9002\u914d\u6240\u6709\u7cfb\u7edf&#xff1a;Windows\/Mac\/Linux \u64cd\u4f5c\u6b65\u9aa4\u7edf\u4e00&#xff0c;\u4ec5\u8def\u5f84\u683c\u5f0f\u7565\u6709\u5dee\u5f02\u3002\u4e8c\u3001\u672c\u5730\u73af\u5883\u524d\u7f6e\u68c0\u67e5 2.1\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/60245.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-15T02:05:31+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/60245.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/60245.html\",\"name\":\"MCP + Cherry Studio \u5b9e\u6218\uff1aMySQL MCP \u670d\u52a1\u642d\u5efa\u4e0e\u5e94\u7528(\u672c\u5730\u90e8\u7f72) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-15T02:05:31+00:00\",\"dateModified\":\"2026-01-15T02:05:31+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/60245.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/60245.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/60245.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MCP + Cherry Studio \u5b9e\u6218\uff1aMySQL MCP \u670d\u52a1\u642d\u5efa\u4e0e\u5e94\u7528(\u672c\u5730\u90e8\u7f72)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MCP + Cherry Studio \u5b9e\u6218\uff1aMySQL MCP \u670d\u52a1\u642d\u5efa\u4e0e\u5e94\u7528(\u672c\u5730\u90e8\u7f72) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/60245.html","og_locale":"zh_CN","og_type":"article","og_title":"MCP + Cherry Studio \u5b9e\u6218\uff1aMySQL MCP \u670d\u52a1\u642d\u5efa\u4e0e\u5e94\u7528(\u672c\u5730\u90e8\u7f72) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u672c\u5730\u90e8\u7f72\u6838\u5fc3\u4f18\u52bf \u6570\u636e\u96f6\u6cc4\u9732&#xff1a;\u6570\u636e\u5e93\u548c MCP \u670d\u52a1\u5747\u8fd0\u884c\u5728\u672c\u5730&#xff0c;\u65e0\u9700\u66b4\u9732\u516c\u7f51&#xff0c;\u7b26\u5408\u4f01\u4e1a\u5185\u7f51\u5b89\u5168\u8981\u6c42&#xff1b;\u65e0\u7f51\u7edc\u4f9d\u8d56&#xff1a;\u65ad\u7f51\u73af\u5883\u4e0b\u4ecd\u53ef\u6b63\u5e38\u8c03\u7528 MySQL MCP \u670d\u52a1&#xff1b;\u8c03\u8bd5\u66f4\u9ad8\u6548&#xff1a;\u672c\u5730\u65e5\u5fd7\u5b9e\u65f6\u67e5\u770b&#xff0c;\u95ee\u9898\u5b9a\u4f4d\u66f4\u5feb&#xff1b;\u9002\u914d\u6240\u6709\u7cfb\u7edf&#xff1a;Windows\/Mac\/Linux \u64cd\u4f5c\u6b65\u9aa4\u7edf\u4e00&#xff0c;\u4ec5\u8def\u5f84\u683c\u5f0f\u7565\u6709\u5dee\u5f02\u3002\u4e8c\u3001\u672c\u5730\u73af\u5883\u524d\u7f6e\u68c0\u67e5 2.1","og_url":"https:\/\/www.wsisp.com\/helps\/60245.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-15T02:05:31+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/60245.html","url":"https:\/\/www.wsisp.com\/helps\/60245.html","name":"MCP + Cherry Studio \u5b9e\u6218\uff1aMySQL MCP \u670d\u52a1\u642d\u5efa\u4e0e\u5e94\u7528(\u672c\u5730\u90e8\u7f72) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-15T02:05:31+00:00","dateModified":"2026-01-15T02:05:31+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/60245.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/60245.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/60245.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"MCP + Cherry Studio \u5b9e\u6218\uff1aMySQL MCP \u670d\u52a1\u642d\u5efa\u4e0e\u5e94\u7528(\u672c\u5730\u90e8\u7f72)"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/60245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=60245"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/60245\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=60245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=60245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=60245"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=60245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}