Koozali.org: home of the SME Server

Broken MySQL root access

Offline edform

  • *
  • 178
  • +0/-0
    • http://www.workgroupsolutions.co.uk
Broken MySQL root access
« on: November 27, 2005, 05:15:45 AM »
After upgrading my 6.0.1 server to MySQL 4.1.10a the root user can no longer access MySQl at the command line, I get access denied, and the denial message states that root isn't using a password.

The server already had an all-privileges-granted user for mysql, and I can log in as that user with the command mysql --user=xxxxx -p, followed by typing the users password at the prompt, but the root password seems to be disengaged in some way.

I discovered the problem when I tried to access webmail after the MySQL update and got the usual error message about line 108 of /home/httpd/html/horde/lib/Prefs/sql.php

I tried the normal cure for this...

/sbin/e-smith/config setprop horde DbPassword horde

and when I ran the post-upgrade and reboot sequence, the MySQL/Horde commands at the end of the boot sequence all failed with error messages about root being denied.

The mysqld log shows...

051127  2:55:34 [Note] /usr/sbin/mysqld: Normal shutdown
051127  2:55:34 [Note] /usr/sbin/mysqld: Shutdown complete
051127 02:55:34  mysqld ended
051127 02:59:17  mysqld started
051127  2:59:17 [Warning] Asked for 196608 thread stack, but got 126976
051127  2:59:17 [Warning] mysql.user table is not updated to new password format; Disabling new password usage until mysql_fix_privilege_tables is run
/usr/sbin/mysqld: ready for connections.
Version: '4.1.10a-standard'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Edition - Standard (GPL)

and the Messages log has this...

Nov 27 02:59:20 ml350 e-smith[2558]: Running event handler: /etc/e-smith/events/local/S06conf-lilo
Nov 27 02:59:20 ml350 e-smith[2558]: S06conf-lilo=action|Event|local|Action|S06conf-lilo|Start|1133060360 782362|End|1133060360 973365|Elapsed|0.191003
Nov 27 02:59:21 ml350 mysql: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Nov 27 02:59:21 ml350 mysql.init: Loading 20horde.mysql_update_privs.sql into mysql failed
Nov 27 02:59:21 ml350 mysql: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Nov 27 02:59:21 ml350 mysql.init: Loading 20mysql_migrate_horde.sql into mysql failed
Nov 27 02:59:21 ml350 mysql: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Nov 27 02:59:21 ml350 mysql.init: Loading 21horde.mysql_set_password.sql into mysql failed
Nov 27 02:59:21 ml350 mysql: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Nov 27 02:59:21 ml350 mysql.init: Loading 30mysql_create_tables.sql into mysql failed
Nov 27 02:59:21 ml350 50turba_upgrade_1.1_to_1.2: DBI->connect(horde) failed: Access denied for user 'horde'@'localhost' (using password: YES) at /etc/e-smith/sql/init/50turba_upgrade_1.1_to_1.2 line 43
Nov 27 02:59:21 ml350 mysql.init: Loading 50turba_upgrade_1.1_to_1.2 into mysql failed
Nov 27 02:59:22 ml350 mysql.init: Loading 60migrate-imp-to-turba into mysql succeeded

Anyone seen this before?

Ed Form

Offline gizzmo2k1

  • **
  • 33
  • +0/-0
    • 7 Fifty-Two
Broken MySQL root access
« Reply #1 on: November 29, 2005, 08:21:55 PM »
Ed,

I had a similar issue, but not during an upgrade.  I messed up the root password myself.

I found this in the forums that works, but it sets mysql back to default (meaning you loose all your databases, thank God for backups).

You should be able to fix it by doing:

runsvctrl d /service/mysqld
rm -rf /var/lib/mysql/*
mv /home/e-smith/db/mysql/mysql.dump ~/mysql.dump.old
signal-event post-upgrade
signal-event reboot


I hope this helps.
............Gizzmo...............
SME 7.2 / P4 2.6Ghz / 320GB SATA / 2GB RAM

Offline edform

  • *
  • 178
  • +0/-0
    • http://www.workgroupsolutions.co.uk
Broken MySQL root access
« Reply #2 on: November 30, 2005, 11:52:35 AM »
Quote from: "gizzmo2k1"

You should be able to fix it by doing:

runsvctrl d /service/mysqld
rm -rf /var/lib/mysql/*
mv /home/e-smith/db/mysql/mysql.dump ~/mysql.dump.old
signal-event post-upgrade
signal-event reboot



Thank's gizzmo,
Sadly the first and third lines didn't work on my machine, although the 'remove' command in line 2 did, and I did get root access back; but when I restored my live databases they didn't work properly. I did a re-install last night, plus I added all my customisations in less than an hour. Then blew the databses back out of dump files and everything is back to normal.

Ed Form

Offline edform

  • *
  • 178
  • +0/-0
    • http://www.workgroupsolutions.co.uk
Broken MySQL root access
« Reply #3 on: December 04, 2005, 02:32:49 PM »
I found an answer to this problem in Dan Brown's 'How to change the MySQL root password in SME Server 5.1.2'

He gives three lines of commands to reset the root mysql password...

# /etc/rc.d/init.d/mysqld stop
# /etc/e-smith/events/actions/conf-mysql-password
# /etc/rc.d/init.d/mysqld start

And they worked a treat.

If anyone has the time to test it, here is a suitably modified Howto for upgrading from mysql 3 to mysql 4...

This changed Howto deals with problems found with update to MySQL 4.1.10a-standard on a box loaded with a customised 6.0.1 server. It adds lines from Dan Brown's 'How to change the MySQL root password in SME Server 5.1.2' to reset the MySQL root access password before attempting to use it to fix the privilege tables etc.

1) DOWNLOAD MySQL 4.0

Download MySQL 4.0 rpms from mysql.com in a fresh directory (Linux x86 RPM downloads section).

You need:

    * MySQL-shared-compat-4.1.x-0.i386.rpm
    * MySQL-server-4.1.x-0.i386.rpm
    * MySQL-client-4.1.x-0.i386.rpm
    * MySQL-devel-4.1.x-0.i386.rpm

Note: replace 4.1.x with current MySql version availaible (was 4.0.18 at time of writing)

2) STOP MYSQL

    service mysqld stop


3) REMOVE OLD RPMS

    rpm -e --nodeps mysql mysql-client mysql-server
    rpm -e mysql-devel
    rpm -e mysqlclient9


4) INSTALL NEW RPMS
Cd to the directory where you downloaded the rpms and do:

    rpm -Uvh MySQL-*.rpm

OR

    rpm -Uhv MySQL-shared-compat-4.1.x-0.i386.rpm
    rpm -Uhv MySQL-server-4.1.x-0.i386.rpm
    rpm -Uhv MySQL-client-4.1.x-0.i386.rpm
    rpm -Uvh MySQL-devel-4.1.x-0.i386.rpm


Note: replace 4.1.x with current MySql version availaible (was 4.0.18 at time of writing)

5) CONFIGURE

    chkconfig --levels 2345 mysql on

    mv /etc/rc.d/init.d/mysql /etc/rc.d/init.d/mysqld
    rm /etc/rc.d/rc7.d/S90mysqld
    ln -s /etc/rc.d/init.d/mysqld /etc/rc.d/rc7.d/S90mysqld

    /sbin/e-smith/config setprop mysqld LocalNetworkingOnly no (to enable remote access)
    /sbin/e-smith/expand-template /root/.my.cnf

    ln -s /usr/sbin/mysqld /usr/libexec/ (for conf-mysql-password script)

Now the added line...

   /etc/e-smith/events/actions/conf-mysql-password

   /etc/rc.d/init.d/mysqld start

Then to make sure that your grant tables are current when you update to the new version:

    /usr/bin/mysql_fix_privilege_tables

More info here: http://dev.mysql.com/doc/mysql/en/Upgrading-grant-tables.html

6) OPTIONAL: INNODB SUPPORT
Create a custom-template fragment:

    mkdir -p /etc/e-smith/templates-custom/etc/my.cnf
    cp /etc/e-smith/templates/etc/my.cnf/009innodb /etc/e-smith/templates-custom/etc/my.cnf
    pico /etc/e-smith/templates-custom/etc/my.cnf/009innodb

And comment the only line it contains so the file should look like this:

#skip-innodb

Save the file then do:

    /sbin/e-smith/expand-template /etc/my.cnf
    service mysqld restart

Offline gizzmo2k1

  • **
  • 33
  • +0/-0
    • 7 Fifty-Two
Broken MySQL root access
« Reply #4 on: December 07, 2005, 06:10:25 PM »
Just note that the commands for resetting the password for mysql are only for SME 6.  There is no # /etc/e-smith/events/actions/conf-mysql-password under SME 7.
............Gizzmo...............
SME 7.2 / P4 2.6Ghz / 320GB SATA / 2GB RAM

Offline jdc0730

  • **
  • 29
  • +0/-0
Broken MySQL root access
« Reply #5 on: January 02, 2006, 06:42:25 PM »
Quote from: "gizzmo2k1"
Just note that the commands for resetting the password for mysql are only for SME 6.  There is no # /etc/e-smith/events/actions/conf-mysql-password under SME 7.


How does one remove the root password in SME 7?

djohen

Broken MySQL root access
« Reply #6 on: January 19, 2006, 04:57:32 AM »
Quote from: "jdc0730"
Quote from: "gizzmo2k1"
Just note that the commands for resetting the password for mysql are only for SME 6.  There is no # /etc/e-smith/events/actions/conf-mysql-password under SME 7.


How does one remove the root password in SME 7?


I screwed my root permissions as well and used the guidelines from the following document (unix section).
http://dev.mysql.com/doc/refman/4.1/en/resetting-permissions.html

 In a Unix environment, the procedure for resetting the root password is as follows:

   1.

      Log on to your system as either the Unix root user or as the same user that the mysqld server runs as.
   2.

      Locate the .pid file that contains the server's process ID. The exact location and name of this file depend on your distribution, hostname, and configuration. Common locations are /var/lib/mysql/, /var/run/mysqld/, and /usr/local/mysql/data/. Generally, the filename has the extension of .pid and begins with either mysqld or your system's hostname.

      You can stop the MySQL server by sending a normal kill (not kill -9) to the mysqld process, using the pathname of the .pid file in the following command:

shell> kill cat /mysql-data-directory/host_name.pid

      Note the use of backticks rather than forward quotes with the cat command; these cause the output of cat to be substituted into the kill command.
   3.

      Create a text file and place the following command within it on a single line:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPassword');

      Save the file with any name. For this example the file will be ~/mysql-init.
   4.

      Restart the MySQL server with the special --init-file=~/mysql-init option:

shell> mysqld_safe --init-file=~/mysql-init &

      The contents of the init-file are executed at server startup, changing the root password. After the server has started successfully you should delete ~/mysql-init.
   5.

      You should be able to connect using the new password.

Alternatively, on any platform, you can set the new password using the mysql client(but this approach is less secure):

   1.

      Stop mysqld and restart it with the --skip-grant-tables --user=root options (Windows users omit the --user=root portion).
   2.

      Connect to the mysqld server with this command:

shell> mysql -u root

   3.

      Issue the following statements in the mysql client:

mysql> UPDATE mysql.user SET Password=PASSWORD('newpwd')
    ->                   WHERE User='root';
mysql> FLUSH PRIVILEGES;

      Replace “newpwd” with the actual root password that you want to use.
   4.

      You should be able to connect using the new password.