1

Linux (Ubuntu 18.04) user, executed the following commands using this tutorial:

  807  sudo apt-get update
  808  sudo apt-get install mysql-server
  809  sudo ufw allow mysql
  810  systemctl start mysql
  811  systemctl enable mysql
  812  /usr/bin/mysql -u root -p

The output from the last line is:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I get the same result without the -p:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Any ideas? I've tried uninstalling and reinstalling several times, and the password I input at the prompts was my root password.

EDIT: I have tried both with and without sudo, I still get the same results

My Linux version:

Distributor ID: Ubuntu
Description:    Bodhi Linux 5
Release:        18.04
Codename:       bionic

My MySQL version:

mysql  Ver 14.14 Distrib 5.7.25, for Linux (x86_64) using  EditLine wrapper
Jessica Chambers
  • 1,246
  • 5
  • 28
  • 56
  • 1
    Try and run mysql with `sudo` and if that works, follow the top answer [here](https://askubuntu.com/questions/766334/cant-login-as-mysql-user-root-from-normal-user-account-in-ubuntu-16-04) – PsychoMantis Feb 04 '19 at 15:54
  • @Tim even with sudo I get the same result – Jessica Chambers Feb 05 '19 at 08:49
  • Even without -p? – PsychoMantis Feb 05 '19 at 08:52
  • Try sudo with mysql -u root -p – Anuj Vishwakarma Feb 05 '19 at 08:53
  • @Tim even without -p – Jessica Chambers Feb 05 '19 at 09:12
  • @AnujVishwakarma I have, the result is still the same – Jessica Chambers Feb 05 '19 at 09:13
  • @JessicaChambers your mySql version ? – Anuj Vishwakarma Feb 05 '19 at 09:31
  • @AnujVishwakarma here it is, I'll add it to the post too `mysql Ver 14.14 Distrib 5.7.25, for Linux (x86_64) using EditLine wrapper` – Jessica Chambers Feb 05 '19 at 09:32
  • You can check here (answer by Lahiru), see if it works: https://stackoverflow.com/questions/21944936/error-1045-28000-access-denied-for-user-rootlocalhost-using-password-y/42967789#42967789 – Anuj Vishwakarma Feb 05 '19 at 09:35
  • @AnujVishwakarma I don't even have the log file, I think my installation must be going wrong somewhere? No errors were thrown during though: ` /var/log/mysqld.log: No such file or directory` – Jessica Chambers Feb 05 '19 at 09:37
  • For the log file try : sudo grep 'temporary password' /var/log/mysql/error.log – Anuj Vishwakarma Feb 05 '19 at 09:39
  • @AnujVishwakarma that returns nothing – Jessica Chambers Feb 05 '19 at 09:41
  • Can you show us some logs or any error ? .., Try to stop the mySql service then. , sudo service mysql stop or $ sudo /usr/local/mysql/support-files/mysql.server stop , Start it in safe mode: , $ sudo mysqld_safe --skip-grant-tables --skip-networking , $ mysql -u root – Anuj Vishwakarma Feb 05 '19 at 09:42
  • Which ones would be of interest? when I try ` sudo grep 'temporary password' /var/log/mysqld.log ` I'm told that the file doesn't exist, and when I try ` sudo grep 'temporary password' /var/log/mysql/error.log ` I get no output at all. I have also tried ` sudo grep 'password' /var/log/mysql/error.log ` and I got about 20 lines like this: `2019-02-04T15:20:53.069385Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)` – Jessica Chambers Feb 05 '19 at 09:46
  • `sudo grep 'password' /var/log/mysql/error.log` also gives these lines: `2019-02-04T15:20:53.072664Z 0 [Note] Shutting down plugin 'validate_password' 2019-02-04T15:20:54.839357Z 0 [Note] Shutting down plugin 'sha256_password' 2019-02-04T15:20:54.839366Z 0 [Note] Shutting down plugin 'mysql_native_password'` – Jessica Chambers Feb 05 '19 at 09:46
  • Did you tried the above one, starting mysql in safe mode as I stated above ? – Anuj Vishwakarma Feb 05 '19 at 10:10
  • @AnujVishwakarma safe mode? Which one is that? I have tried every suggestion in this thread, nothing has worked so far – Jessica Chambers Feb 05 '19 at 10:11
  • This one : Try to stop the mySql service then. , sudo service mysql stop or $ sudo /usr/local/mysql/support-files/mysql.server stop , Start it in safe mode: , $ sudo mysqld_safe --skip-grant-tables --skip-networking , $ mysql -u root – Anuj Vishwakarma Feb 05 '19 at 10:12
  • @AnujVishwakarma safe mode gives me this: `2019-02-05T10:13:49.233122Z mysqld_safe Logging to syslog. 2019-02-05T10:13:49.247554Z mysqld_safe Logging to '/var/log/mysql/error.log'. 2019-02-05T10:13:49.279705Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.` – Jessica Chambers Feb 05 '19 at 10:14
  • when I do `mysql -u root` I get : `ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)` – Jessica Chambers Feb 05 '19 at 10:15
  • So I used this answer https://stackoverflow.com/a/42169345/6187682 and it gets stuck at `2019-02-05T10:20:18.704064Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql` – Jessica Chambers Feb 05 '19 at 10:23

2 Answers2

1

Jessica, I tried the exact steps from the link you provided (rackspace). I am using 18.04 LTS. The step should be below when you invoke mysql. It worked perfectly fine for me. Also, in my case the mysql_secure_installation utility did not run automatic. So i had to invoke just "sudo mysql" and then updated the password for root.

sudo mysql -u root -p
Svj
  • 231
  • 2
  • 10
0

I tidied up my system with:

sudo apt-get --purge autoremove mysql-server then reinstalled it per the tutorial, the problem seems to have been resolved.

Jessica Chambers
  • 1,246
  • 5
  • 28
  • 56