简体   繁体   中英

MySQL: can't access root or command prompt

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, 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM