Access denied for root@localhost

  • Moderator

    I think maybe Ubuntu pushed a patch to fix the upgrade thing? I can’t reproduce it any longer anyway.

    Anyway, after running that command inside of mysql I can now connect as a regular user to the database and the schema updater no longer shows up!

  • Developer

    @Quazz From what you said I guess you already got past the mysql startup and conversation issue. It’s just the login that does not work. Found this:

    If you install 5.7 and don’t provide a password to the root user, it will use the auth_socket plugin. That plugin doesn’t care and doesn’t need a password. It just checks if the user is connecting using a UNIX socket and then compares the username.

    So the simple fix is to login as root via command line client and run ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''; (will set an empty password again and more importantly sets it to native password login). Then go back to the web gui and I am pretty sure it won’t come up with the schemaupdater!

    EDIT: I ran into “big trouble” with FOG and MySQL 5.7… You won’t be able to create any new DB entries (new hosts, groups, tasks) as the auto increment ID field seems to behave a little different.

  • Developer

    @Quazz Confirmed (ubuntu) issue:

    Checking if update is needed.
    Checking server version.
    Error: Server version (5.5.49-0ubuntu0.14.04.1) does not match with the version of
    the server (5.7.12) with which this program was built/distributed. You can
    use --skip-version-check to skip this check.
    mysql_upgrade failed with exit status 3
    dpkg: error processing package mysql-server-5.7 (--configure):
     subprocess installed post-installation script returned error exit status 1
    dpkg: dependency problems prevent configuration of mysql-server:
     mysql-server depends on mysql-server-5.7; however:
      Package mysql-server-5.7 is not configured yet.
    dpkg: error processing package mysql-server (--configure):
     dependency problems - leaving unconfigured
    Errors were encountered while processing:
    Current status: 0 updates [-272].

    I am still not exactly sure what’s going on. Interestingly enough I seem to have solved this just by stopping and starting the mysql service (service mysql stop; service mysql start) as it did not complain about the version mismatch anymore when I tried running mysql_upgrade by hand after the service restart:

    # su -s /bin/bash mysql
    $ mysql_upgrade
    Checking if update is needed.
    This installation of MySQL is already upgraded to 5.7.12, use --force if you still need to run mysql_upgrade

    But I seem to be caught in a “deadlock” now because I cannot clean up the install via aptitude -f install as it always fails when trying to talk to the older 5.5.49 mysql that is still running. The problem as I understand it is that the old DB needs to be up because the installer script runs mysql_upgrad which would fail if no DB is running. On the other hand if the old DB is up the new one cannot start because the files are locked. This is absolutely stupid. Why doesn’t it shutdown the old DB before trying to startup the new on?!?!

    EDIT: I finally got around this by opening two shells. First run aptitude -f install and wait till you saw the message “This installation of MySQL is already upgraded to 5.7.12…”, then run service mysql stop to shutdown the old DB. Now I finally have only the new DB installed and starting/stopping using the init scripts is working fine again (new DB as I can see in /var/log/mysql/error.log)!

  • Moderator

    @Sebastian-Roth At home now, but the error I got on the fog schema updater was :

    Access denied for ‘root’@‘localhost’. Please check if the database is running.

    Using sudo mysql -u root through ssh gave me access no problem.

    Using mysql -u root gave the Access denied for ‘root’@‘localhost’ error (I believe it was number 1696 or so?)

    But your comment gave me an idea to move the var/lib/mysql and reinstall.

    Tom had a brief session before my internet cut out and after that I had to sort out our dhcp server first since apparmor didn’t allow it to create new dhcp lease files (still doesn’t, but it’s in complain mode now), so we’re guessing this error has something to do with ubuntu 16.04 specifically.

  • Developer

    @Quazz Well then it shouldn’t be a problem for the web gui to connect?! Can you please show us the exact error you see so we might have a better idea on where to dig.

  • Moderator

    @Sebastian-Roth The problem is, there is no password set!

  • Developer

    @Quazz said:

    So I removed all mysql with remove --purge

    AFAIK even purging the package does not remove /var/lib/mysql and therefore does not remove the mysql user tables with all your passwords set.

    Try mysql -u root -p and it will ask you for a password!

  • Moderator

    @Tom-Elliott mysql-server is most definitely installed, it just isn’t able to login into mysql as a regular user, only using sudo or as root.

    I assume FOG tries to login as a regular user (fog user most likely?) which fails like it does when I try it manually of course.

    Would it be possible to simply install mariadbserver and try that?

  • Senior Developer

    I’m not aware of there being an issue at all. The mysql-server script is in the installer in lib/ubuntu/

    If, for whatever reason, it cannot find the mysql-server in the list, it will check for

    sqlserverlist="mysql-server mariadb-server mariadb-galera-server MariaDB-server MariaDB-Galera-server"

    If none of those exist, then something else has gone horribly wrong.

  • Hi, I have the same problem when “install/upgrade” the database in a fresh install

Log in to reply