1

I installed the following mysql client on my server 'mysql Ver 8.0.25-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))' and went through mysql_secure_installation steps and set the password as asked through this process. In the shell im logged in as root, I wonder if this has anything to do with mysql not asking for a pasword when I use put this command? Basically, i type mysql into my terminal, and I get mysql - not promting for any passwords.

5 Answers 5

2

The reason is that MySQL uses socket authentication option by default for the root user.

If you want to disable it, you need to change Authentication plugin for the root account from "Socket authentication" to "Native MySQL authentication".

3

Probably socket authentication where MySQL basically authenticates you if the username calling the mysql binary matches a known username to MySQL.

The server-side auth_socket authentication plugin authenticates clients that connect from the local host through the Unix socket file. The plugin uses the SO_PEERCRED socket option to obtain information about the user running the client program. Thus, the plugin can be used only on systems that support the SO_PEERCRED option, such as Linux.

1

You most likely saved your credentials in the .my.cnf file.

2
  • how can i force mysql command to prompt for password everytime i enter my localhost mysql enviroment? if those credentials were saved in some location through mysql_secure_installtion process how do I force these into action? right now anyone to my server can access my database without using any passwords, its laughable. Jul 5, 2021 at 15:35
  • After setting root password why does MYSQL still allow me to login/access mysql console without a password? Jul 5, 2021 at 15:51
0

The mysql-server package comes pre configured with a utility called mysql_secure_installation that is used to set up a secure starting point for MySQL server, by deleting anonymous users and allowing you to specify the desired password strength policy.

mysql_secure_installation is a shell script available on Unix systems, and enables you to secure the MySQL installation by enabling you to:

  1. Set a password for root accounts
  2. List item remove root accounts that are accessible from outside the local host
  3. Remove anonymous-user accounts
  4. Remove the test database, which by default can be accessed by anonymous users

Run the command below to secure MySQL after installing mysql-server.

$ sudo mysql_secure_installation

To connect to MySQL run the below command:

$ mysql -u root -p
0

You should check in /var/log/mysql, as some package maintainers set the application so it logs there the initial password.

You should use that password, or stop the service, and start it passwordless by launching "mysqld_safe --skip-grant-tables" and then change root password with

You must log in to answer this question.

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