You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

修改my.cnf后URL路径显示主目录,无法移除该怎么办?

Fixing MySQL {username} Path Issue by Tracking Down Your Modified my.cnf

Hey there, let's tackle this problem step by step. I've run into similar config file hunting issues with MySQL before, so I know how frustrating it is when you can't track down a change you made months ago. Here's how to get to the bottom of it:

Step 1: Locate all possible my.cnf files MySQL uses

MySQL reads config files from multiple locations depending on your OS and installation method. Use these commands to find exactly which files your instance is loading:

  1. Check via terminal command:
    Run this in your shell to see the default config file search order MySQL follows:

    mysql --help | grep -A 1 "Default options"
    

    You'll get output like this, listing all potential config paths:

    Default options are read from the following files in the given order:
    /etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
    
  2. Find the actively used config file directly in MySQL:
    Log into your MySQL shell with mysql -u [your-username] -p, then run this query to get the exact path of the config file your running instance uses:

    SHOW VARIABLES LIKE 'config_file';
    

    This is the most reliable way to pinpoint the file you modified earlier.

Step 2: Fix the problematic pid-file configuration

Once you've found the correct my.cnf file, open it with a text editor (e.g., sudo nano /path/to/your/my.cnf). Look for the invalid line you added:

pid-file edit

This is a malformed setting—pid-file requires a valid file path (like pid-file = /var/run/mysqld/mysqld.pid), not the word "edit". Remove this line entirely, or replace it with a proper pid file path if you need that configuration.

Step 3: Restart MySQL to apply changes

Save the corrected config file, then restart your MySQL service to make sure changes take effect. Use the command matching your OS:

  • For systemd-based systems (Ubuntu 16.04+, CentOS 7+):
    sudo systemctl restart mysql
    
  • For older init.d systems:
    sudo service mysql restart
    

After restarting, check if the {username} path issue is resolved. If it persists, double-check that you modified the correct config file (use the SHOW VARIABLES LIKE 'config_file'; query again to confirm) and that the invalid line was fully removed.

内容的提问来源于stack exchange,提问作者codo7081

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 09:08:12