How to Login to MySQL Database after the Installation :

After the installation of MySQL, as a DBA we need to login to the database. Here is the article today we will learn how to login to MySQL database after the installation.

Steps to login to MySQL Database after the installation :

1. First we need to find the password from mysqld.log.
[root@vm3 mysql1]# cat /var/log/mysqld.log | grep password
2023-12-08T18:23:32.191694Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: :eTlVidc6IoD
[root@vm3 mysql1]# 
2. Execute the below command and it will ask for the password. Then you can enter the above password and you will be able to login. But you will get one error that you must reset your password as below :
[root@vm3 mysql1]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.35

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
3. To resolve this, you have to alter your password and reset it with a new password. Execute the below command :
mysql> alter user root@localhost identified by 'Mysql@987';
Query OK, 0 rows affected (0.02 sec)

mysql>  flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql>  show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.02 sec)
4. Exit and next time log in with the new password that you reset last time. Congratulations!! you are now able to login to MySQL database successfully.
Login to MySQL Database after the Installation

So, here are the steps that can help you to login to MySQL database after installation. Also you can follow the MySQL documentation for the same.

This Post Has One Comment

Leave a Reply