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

使用带账号密码的mysql --defaults-extra-file提示‘Access denied’问题

Troubleshooting "Access denied" Error for Koha MySQL Setup on Ubuntu 16.04

Let's break down the possible causes and fixes for your access denied issue when running the Koha installation script. Here's what to check step by step:

1. Fix the MySQL Command Parameter Typo

First, I notice you're using --defaults-file-extra in your command—this is likely a typo. MySQL's correct parameter for loading an extra config file is --defaults-extra-file. A wrong parameter means MySQL isn't reading your koha-common.cnf at all, falling back to default credentials which trigger the access error.

Test the corrected command manually first to confirm:

mysql --defaults-extra-file=/etc/mysql/koha-common.cnf

2. Verify the debian-sys-maint User Credentials Match

The debian-sys-maint user is managed by Debian's MySQL packages, but sometimes the password in /etc/mysql/debian.cnf can get out of sync with what's stored in MySQL. Here's how to check and fix this:

Step 2.1: Check the current password in MySQL

Log into MySQL as root (you may need sudo mysql -u root if no root password is set):

SELECT user, authentication_string, host FROM mysql.user WHERE user = 'debian-sys-maint';

Step 2.2: Compare with /etc/mysql/debian.cnf

Open the config file to check its stored password:

cat /etc/mysql/debian.cnf

If the password field under [client] doesn't match the authentication_string from the MySQL query, update the user's password in MySQL:

ALTER USER 'debian-sys-maint'@'localhost' IDENTIFIED BY 'thepassword'; -- Replace 'thepassword' with the value from debian.cnf
FLUSH PRIVILEGES;

Ensure the koha-common.cnf symlink points correctly to debian.cnf, and that the user running the Koha script has read access to both files:

ls -l /etc/mysql/koha-common.cnf

You should see output like this (confirming the link is intact):

lrwxrwxrwx 1 root root 24 Jul 10 12:34 /etc/mysql/koha-common.cnf -> /etc/mysql/debian.cnf

If the link is broken, recreate it:

sudo ln -sf /etc/mysql/debian.cnf /etc/mysql/koha-common.cnf

Step 3.2: Check file permissions

Both files should be readable by the user executing the Koha script (usually the koha user or your current user). Check permissions with:

ls -l /etc/mysql/debian.cnf

The ideal permissions are -rw-r----- (owner root, group root, read access for owner and group). If the Koha user can't read the file, you can temporarily grant global read access (safe for private servers):

sudo chmod o+r /etc/mysql/debian.cnf

4. Confirm MySQL Socket Path is Correct

The debian.cnf specifies socket = /var/run/mysqld/mysqld.sock—make sure this file exists and is accessible:

Step 4.1: Check if the socket exists

ls -l /var/run/mysqld/mysqld.sock

If it doesn't exist, MySQL might not be running. Start or restart the service:

sudo systemctl restart mysql

Step 4.2: Verify socket permissions

The socket should be owned by mysql:mysql with permissions srwxrwxrwx (read/write for all). Fix permissions if needed:

sudo chown mysql:mysql /var/run/mysqld/mysqld.sock
sudo chmod 777 /var/run/mysqld/mysqld.sock

5. Test the Connection Manually

After trying the above steps, test the connection again with the corrected command to confirm it works:

mysql --defaults-extra-file=/etc/mysql/koha-common.cnf -e "SELECT 1;"

If this returns a result like +---+ | 1 | +---+ | 1 | +---+, the connection is successful, and you can re-run the Koha installation script.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 09:28:14