Operating System & Version
Centos 6.10
cPanel & WHM Version
86.0.13

Jon Erickson

Member
Apr 16, 2019
10
0
1
USA
cPanel Access Level
Root Administrator
Running into the following error with the automated mysqlcheck script.
Code:
mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect
I am getting an access denied error when the script is run automatically. I've confirmed the root password and it is also set properly in /root/.my.cnf. I can run the command below using the password and it works correctly.
Bash:
mysqlcheck -u root -p --all-databases
The error also occurs when proceeding to Repair a MySQL database in WHM. Is the script using a different password?
 

Jon Erickson

Member
Apr 16, 2019
10
0
1
USA
cPanel Access Level
Root Administrator
Sorry for all the posts but I seem to have fixed it. I had to use mysql_config_editor to reset the client login-path with the right username and password. For some reason when I change the root password in WHM, it does not update .mylogin.cnf but it does change .my.cnf. Do you know why this might be,
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,300
363
Houston
@cPanelLauren

This is your companies script. I didn't create it. I am not actually sure where to find it. It's not easy to tell in the /scripts folder. All I know is it appears to be executing with the system cron.
Your response does not indicate what is running, I have no way to know if its a customization or something provided by cPanel or otherwise. It's always best to be detailed in your threads, we don't have the privilege of having access to your server to view the configuration. It might seem ridiculous to you that we ask some of the questions we do but I guarantee you there is a reason for them being asked.

Neither of the scripts you're referencing in this instance are items that cPanel maintains or provides:

/usr/local/cpanel/3rdparty/bin/mysqlcheck

Code:
MYSQLCHECK(1)                                                                                                                                                                                

NAME
       mysqlcheck - a table maintenance program

SYNOPSIS
       mysqlcheck [options] [db_name [tbl_name ...]]

DESCRIPTION
       The mysqlcheck client performs table maintenance: It checks, repairs, optimizes, or analyzes tables.

       Each table is locked and therefore unavailable to other sessions while it is being processed, although for check operations, the table is locked with a READ lock only. Table maintenance operations can be time-consuming,
       particularly for large tables. If you use the --databases or --all-databases option to process all tables in one or more databases, an invocation of mysqlcheck might take a long time. (This is also true for mysql_upgrade
       because that program invokes mysqlcheck to check all tables and repair them if necessary.)

       mysqlcheck is similar in function to myisamchk, but works differently. The main operational difference is that mysqlcheck must be used when the mysqld server is running, whereas myisamchk should be used when it is not. The
       benefit of using mysqlcheck is that you do not have to stop the server to perform table maintenance.

       mysqlcheck uses the SQL statements CHECK TABLE, REPAIR TABLE, ANALYZE TABLE, and OPTIMIZE TABLE in a convenient way for the user. It determines which statements to use for the operation you want to perform, and then sends the
       statements to the server to be executed.
/usr/local/cpanel/3rdparty/bin/mysql_config_editor
Is a MySQL script:
Code:
# head -50 /usr/local/cpanel/3rdparty/share/man/man1/mysql_config_editor.1
'\" t
.\"     Title: \fBmysql_config_editor\fR
.\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\"      Date: 12/20/2018
.\"    Manual: MySQL Database System
.\"    Source: MySQL 5.6
.\"  Language: English
.\"
.TH "\FBMYSQL_CONFIG_EDITOR\FR" "1" "12/20/2018" "MySQL 5\&.6" "MySQL Database System"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html


With that being said, MySQL is checked periodically if monitored with chksrvd, which would most likely be why the check was being run.

Sorry for all the posts but I seem to have fixed it. I had to use mysql_config_editor to reset the client login-path with the right username and password. For some reason when I change the root password in WHM, it does not update .mylogin.cnf but it does change .my.cnf. Do you know why this might be,
I'd assume this to be because the default installation of mysql on cPanel does not include .mylogin.cnf and as such we're not looking for it when updating the username/password for a mysql user. This is created when you use the mysql_config_editor as described in the MySQL Documentation here: MySQL :: MySQL 5.7 Reference Manual :: 4.6.6 mysql_config_editor — MySQL Configuration Utility

cPanel assumes that you'll be making modifications using the interface, rather than making manual changes.