Quantcast
Channel: Active questions tagged 22.04 - Ask Ubuntu
Viewing all articles
Browse latest Browse all 4437

How do I run mysql_secure_installation on 22.04?

$
0
0

I've just installed MySQL 8.0.36 on Ubuntu 22.04 and now I want to run mysql_secure_installation.

The guide for this precise thing at Digital Ocean indicates that on Ubuntu, running mysql_secure_installation produces a logic loop if you don't configure the MySQL 'root' user's password first. Following its instructions, I did so:

$ sudo mysql[sudo] password for user: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 8Server version: 8.0.36-0ubuntu0.22.04.1 (Ubuntu)Copyright (c) 2000, 2024, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'crocodile69210';Query OK, 0 rows affected (0.00 sec)mysql> exit;Bye

After doing this, I am unable to run mysql_secure_installation at all. When I try, I get a password error:

$ sudo mysql_secure_installationSecuring the MySQL server deployment.Enter password for user root: Error: Access denied for user 'root'@'localhost' (using password: YES)

This happens when I enter both the MySQL 'root' user password that I established earlier (crocodile69210) and my OS sudo password. If I enter no password at all, the result is the same except the last line is(using password: NO).

What do I do to be able to run mysql_secure_installation?

Edit: It appears that the ALTER USER statement above does not actually set a password. If I run $ mysql -u root -p and literally copy and paste the password that I set, which is still visible in the terminal history, I cannot login to mysql:

$ mysql -u root -pEnter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I'm not sure if or how this illuminates the problem.

Edit 2: Working on the theory that the Digital Ocean guide is wrong, I uninstalled MySQL ($ sudo apt remove mysql-server) and then re-installed it. I did not run the ALTER USER command given in the DO article. I still cannot run mysql_secure_installation and get the same "Access denied" password errors I got during the first attempt.

Edit 3:More information

When I first installed mysql-server from a fully blank slate, I was able to use $ sudo mysql immediately to access the MySQL interactive shell. I find that after 1) uninstalling mysql-server using $ sudo apt remove mysql-serverAND 2) fully purging mysql-server using $ sudo apt purge mysql-server, after I reinstall I still can't use $ sudo mysql. I get the "Access denied" password error. So, something about the first installation is obviously still hanging around. Figuring out what this is will likely help solve the whole problem.


Viewing all articles
Browse latest Browse all 4437

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>