Change the content of '/usr/local/lxlabs/kloxo/bin/common/misc/reset-mysql-root-password.php' to:
<?php
include_once "lib/html/include.php";
$tpath = "/usr/local/lxlabs/kloxo/serverfile";
if (isset($argv[1])) {
$pass = $argv[1];
} else {
$pass = randomString(9);
}
$text = <<<EOF
UPDATE mysql.user SET Password=PASSWORD('PASSWORD') WHERE User='USER';
FLUSH PRIVILEGES;
EOF;
$text = str_replace("'USER'", "'root'", $text);
$text = str_replace("'PASSWORD'", "'{$pass}'", $text);
file_put_contents("{$tpath}/reset-mysql-password.sql", $text);
print("Stop MySQL service...\n");
if (isServiceExists('mysqld')) {
exec("service mysqld stop");
} else {
exec("service mysql stop");
}
print("MySQL ROOT password reset...\n");
sleep(10);
system("mysqld_safe --skip-grant-tables --init-file={$tpath}/reset-mysql-password.sql >/dev/null 2>&1 &");
sleep(15);
// MR -- need restart because need stop mysqld_safe before
print("Restart MySQL service...\n");
if (isServiceExists('mysqld')) {
exec("service mysqld restart");
} else {
exec("service mysql restart");
}
exec("'rm' -f {$tpath}/reset-mysql-password.sql");
print("- Test Connecting:\n");
if ($conn->connect_errno) {
print(" * Failed to connect to MySQL: " . $conn->connect_error . "\n");
log_error($conn->connect_error);
} else {
print(" * Success\n");
}
print("- Save to 'dbadmin' in slavedb\n");
$a['mysql']['dbpassword'] = $pass;
slave_save_db("dbadmin", $a);
/*
$text2 = <<<EOF
REPLACE INTO dbadmin (nname, parent_clname, parent_cmlist, dbtype, dbadmin_name, dbpassword, syncserver, oldsyncserver, olddeleteflag) VALUES
('mysql___localhost', 'pserver-localhost', '', 'mysql', 'root', 'PASSWORD', 'localhost', '', '');
COMMIT;
EOF;
*/
if (!empty(mysql_fetch_array(mysql_query("SHOW DATABASES LIKE '$dbname' ")))) {
$text2 = <<<EOF
UPDATE dbadmin SET dbpassword='PASSWORD' WHERE nname='mysql___localhost' AND dbtype='mysql' AND dbadmin_name='root';
COMMIT;
EOF;
$text2 = str_replace("'PASSWORD'", "'{$pass}'", $text2);
print("- Update to 'dbadmin' in 'kloxo' database\n");
exec("mysql -u root -p'{$pass}' kloxo -e \"{$text2}\"");
}
$conn->close();
and then try again 'sh /script/reset-mysql-root-password'