Score:1

Installed MySQL server but mysql command does not ask for password in the shell

in flag

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.

Score:3
ar flag

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.

Score:2
us flag

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".

Score:0
cz flag

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

MediumMatrix avatar
in flag
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.
MediumMatrix avatar
in flag
After setting root password why does MYSQL still allow me to login/access mysql console without a password?
Score:0
kr flag

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

Score:0
ng flag

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
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.