0

T he version installed on my machine.Details as follows:

mandar@~:$ mysql --version mysql Ver 8.0.31-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))

mysql is running ---

mandar@~:$ sudo systemctl status mysql ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2023-01-11 12:53:58 IST; 7min ago Process: 180517 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 180525 (mysqld) Status: "Server is operational" Tasks: 39 (limit: 37674) Memory: 364.3M CPU: 2.622s CGroup: /system.slice/mysql.service └─180525 /usr/sbin/mysqld

Jan 11 12:53:56 coeus systemd[1]: Starting MySQL Community Server... Jan 11 12:53:58 coeus systemd[1]: Started MySQL Community Server.

mandar@~:$ sudo mysql

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

I am not able to get mysql prompt .. I have not set any password .

mandar@~:$ sudo mysql -u root ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

I have tried to start sql in safe mode using following command

sudo mysqld_safe --skip-grant-tables &

Error Message mandar@~:$ 2023-01-11T06:19:33.781251Z mysqld_safe Logging to '/var/log/mysql/error.log'. 2023-01-11T06:19:33.782132Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists. I also tried to complete the secure installation

mandar@~:$ sudo mysql_secure_installation [sudo] password for mandar:

Securing the MySQL server deployment.

Enter password for user root: Error: Access denied for user 'root'@'localhost' (using password: YES)

mandar@~:$ mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) what am I doing wrong ?

1 Answers1

1

If you haven't set the password and the username is root try

mysql -u root -p

it will ask for password press enter without typing anything, if you are using ubuntu:

sudo mysql -u root -p

You can follow the Digital Ocean Tutorial for step by step installation guide.

Jeybin George
  • 448
  • 2
  • 8
  • I tried as you suggested. it asked for sudo password . But the error continues- mandar@~:$ sudo mysql -u root -p [sudo] password for mandar: Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) [digitalocen ] (https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04) requires access to the sql prompt , which I am not able to get since I don't have password . – Mandar Gite Jan 11 '23 at 08:26
  • @MandarGite this link might help you : https://stackoverflow.com/questions/16556497/mysql-how-to-reset-or-change-the-mysql-root-password – Jeybin George Jan 11 '23 at 09:06