13

Im trying to install mysql and I get the error:

mysql_upgrade: Got error: 1045: Access denied for user 'debian-sys-maint'@'localhost' (using password: YES) while connecting to the MySQL server

After some searching, I find this is perhaps giving access to debian-sys-maint, so I did this:

sudo cat /etc/mysql/debian.cnf

Then set the debian password in mysql:

mysql -u root -p <password>
GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'password-here';

Then I restart:

sudo /etc/init.d/mysql restart

And try and configure again:

sudo dpkg --configure -a

I get the same error.

4
  • 2
    stackoverflow.com/questions/11644300/…
    – Rinzwind
    Commented Oct 11, 2016 at 11:01
  • Rinzwind, that answer has exactly what ive already tried.
    – panthro
    Commented Oct 11, 2016 at 11:02
  • is there a .my.cnf in root's home dir or in /var/lib/mysql which may contain user data for deb-sys-maint? Commented Oct 11, 2016 at 11:28
  • Nothing in root, I get permission denied when trying to cd /var/lib/mysql
    – panthro
    Commented Oct 11, 2016 at 11:32

2 Answers 2

6

A bit late but here it is: Firstly I'm on

Distributor ID: Ubuntu
Description:    Ubuntu 16.10
Release:    16.10
Codename:   yakkety

I had to "uncheck" some software repositories. It can be easily done on Software & Updates GUI on the Other Software tab. I unchecked:

  • unstable repos
  • xenial repos
  • "disabled on upgrade to yakkety" repositories

The only checked repositories for me were:

software&updates window

Then, I solved the problem this way:

sudo su

root@1w3j: mysql -u root -p
Enter password:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<your password>';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

If the error(1819) is raised, type this on the mysql terminal

mysql> uninstall plugin validate_password;

Then restart mysql: systemctl restart mysql

Finally

apt install -f

to fix broken dependencies

If error continues, enter again to mysql terminal, login: type this:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<your password>'

apt -f install for the last time.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libmecab2
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-5.7 (5.7.17-0ubuntu0.16.10.1) ...
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
The sys schema is already up to date (version 1.5.1).
Checking databases.

(your databases will be shown here...)

Upgrade process completed successfully.
Checking if update is needed.
Setting up mysql-server (5.7.17-0ubuntu0.16.10.1) ...

Other way to solve was: apt -u dist-upgrade

2
  • I can't believe that worked! :-D How did you figure that out? Commented Feb 22, 2020 at 16:26
  • This worked for me on Ubuntu 16.04 Commented Feb 22, 2020 at 16:36
1

This is coming after a lot of attempt at answering the question

Check the Users on the MYSQL installation

 mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
 +-----------+-------------------------------------------+-----------------------+-----------+
 | User      | authentication_string                     | plugin                | Host      |
 +-----------+-------------------------------------------+-----------------------+-----------+
 | root      | *4C856331B587C990CC0D06E7EC93CB2D7A2CAD5F | mysql_native_password | localhost |
 | mysql     | invalid                                   | mysql_native_password | localhost |
 | wordpress | *2D2CF7300069DAB3433A5A0F49B92407769EBC56 | mysql_native_password | localhost |
 +-----------+-------------------------------------------+-----------------------+-----------+

Create the Debian-sys-maint User

 mysql> CREATE USER 'debian-sys-maint'@'localhost' IDENTIFIED BY 'password';

Use the same password in the debian.cnf file

user@system:~$ sudo cat /etc/mysql/debian.cnf

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = **n4aSHUP04s1J32X5**
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
user     = debian-sys-maint
password = **n4aSHUP04s1J32X5**
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

mysql> CREATE USER 'debian-sys-maint'@'localhost' IDENTIFIED BY 'n4aSHUP04s1J32X5';

Grant the Debian-sys-maint user access

mysql> GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> EXIT

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .