Thursday, 5 June 2025

Different Ways to Change Passwords in MySQL

 

Topic: Different Ways to Change Passwords in MySQL   


Password change activity is also a critical task for the database administrator. Why is this activity so critical? The reason is that changing/resetting the password of the users (Accounts) is the single command for the database Admin, even nowadays, some people are doing password change activity through automation means, it is a simple or easy task for the DBA. But the main task is after the password change activity; if the application team doesn’t know which application and script are using the current password, then it will cause the password lock issue. To avoid account lock issues after password reset activity, later version 8.0.14 MySQL introduces the feature called retain current password to hold the old and new passwords until you discard the old password manually.

 

1.       Password change commands before the 8.0.14 version

 

-          Change using the Alter command

mysql> select current_user();

+----------------+

| current_user() |

+----------------+

| root@localhost |

+----------------+

1 row in set (0.00 sec)

 

mysql> alter user test01@localhost identified by 'Admin_1234';

Query OK, 0 rows affected (0.01 sec)

 

mysql> exit

[mysql@mysql-se tmp]$ mysql -u test01 -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 18

Server version: 8.4.5 MySQL Community Server - GPL

 

Copyright (c) 2000, 2025, 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> select current_user();

+------------------+

| current_user()   |

+------------------+

| test01@localhost |

+------------------+

1 row in set (0.00 sec)

 

mysql>

 

-          Reset password using the SET command

[mysql@mysql-se tmp]$ mysql -u test01 -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 19

Server version: 8.4.5 MySQL Community Server - GPL

 

Copyright (c) 2000, 2025, 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>

mysql>

mysql> select current_user();

+------------------+

| current_user()   |

+------------------+

| test01@localhost |

+------------------+

1 row in set (0.00 sec)

 

mysql> set password for test01@localhost="Admin_5678";

Query OK, 0 rows affected (0.01 sec)

 

mysql> exit

Bye

 

[mysql@mysql-se tmp]$ mysql -u test01 -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 20

Server version: 8.4.5 MySQL Community Server - GPL

 

Copyright (c) 2000, 2025, 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> select current_user();

+------------------+

| current_user()   |

+------------------+

| test01@localhost |

+------------------+

1 row in set (0.00 sec)


mysql>

INFORMATION: The SET and ALTER password commands can be executed for the same user prompt and root password


2.       New password change commands in the 8.0.14 version


In later version 8.0.14, version user account can hold two passwords. One old password and another new password. which helps when you don’t know the exact count, where you are using the user account and its password, and you want to change the user password due to the password change policy. you can change the new password in the application and scripts, which you know other applications and scripts still use the old password utile you discard it. you can manually discard it using the discard command. This method of changing passwords helps to avoid the outages after the password change activity.

 

-          Connect to the user and change the password using ‘Retain Current Password

[mysql@mysql-se tmp]$ mysql -u test01 -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 20

Server version: 8.4.5 MySQL Community Server - GPL

 

Copyright (c) 2000, 2025, 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> select current_user();

+------------------+

| current_user()   |

+------------------+

| test01@localhost |

+------------------+

1 row in set (0.00 sec)

mysql> alter user test01@localhost identified by 'Weltest_8976' RETAIN CURRENT PASSWORD;

Query OK, 0 rows affected (0.00 sec)

 

mysql> exit

Bye

[mysql@mysql-se tmp]$

Install and configure MySQL community 8.0 on Oracle Linux 8.0


Upgrade in MySQL generally refers to updating the MySQL Cluster (Server) to a newer version, either a minor or major release, to benefit from bug fixes, new features, and performance enhancements. It also involves using the mysql_upgrade script to ensure your database schemas are compatible with the updated server.

In MySQL, the first two numbers of the version number represent the major version, while the last number indicates the minor version. A major version bump usually signifies incompatible changes or a new major feature set, while a minor version update typically introduces new features or bug fixes while maintaining backward compatibility.

Implementation Diagram:


Infrastructure Diagram:


In this QuickStart, we learn how to:

  • Download and configure MySQL 8.0 repos
  • Install MySQL 8.0  
  • Check and configure the root password
  • Connect the MySQL cluster
  • Validation

Step-01 Download and configure MySQL 8.0 repos

-          Download the MySQL SE repository from the below URL

https://dev.mysql.com/downloads/repo/yum/



-          Configure the MySQL repository

[root@mysql-se ~]# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023 

[root@mysql-se ~]# cd /etc/yum.repos.d/

[root@mysql-se yum.repos.d]# ls -ltr mysql-community.repo

-rw-r--r--. 1 root root 2755 Apr 22  2024 mysql-community.repo

[root@mysql-se yum.repos.d]# sed -i 's/enabled=1/enabled=0/' mysql-community.repo

[root@mysql-se yum.repos.d]#

[root@mysql-se ~]# sed -i 's/enabled=1/enabled=0/' mysql-community.repo


Step-02: Install MySQL 8.0  

[root@mysql-se yum.repos.d]# dnf  --enablerepo=mysql80-community  list available | grep  mysql-community-server







Step-03 Check and configure the root password

-          First, enable the MySQL user login

[root@mysql-se yum.repos.d]# cat /etc/passwd | grep -i mysql

mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/false

to

mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/Bash

-          Start the MySQL Daemon Service using the systemctl command

[root@mysql-se ~]# systemctl status mysqld

[root@mysql-se ~]# systemctl start mysqld

[root@mysql-se ~]# systemctl status mysqld




-          Check the MySQL version

[root@mysql-se ~]# mysql –version


-          Get the MySQL root password from MySQL service log

[root@mysql-se ~]# cat /var/log/mysqld.log | grep -i ‘temporary password’

-          Login to MySQL user and configure the secure password using mysql_secure_installation utility

[root@mysql-se ~]# sudo su - mysql

[mysql@mysql-se ~]$ cd /usr/bin/

[mysql@mysql-se bin]$ ls -ltr mysql_secure_*

-rwxr-xr-x. 1 root root 7387792 Mar 31 06:25 mysql_secure_installation

[mysql@mysql-se bin]$






Step-04 Connect to MySQL cluster


Step-5 Validate the MySQL Cluster

mysql> show databases;

mysql> select version();



Monday, 1 January 2024

work on autovacuum postgreSQL parameter

 In This blog, we are discussing the auto vacuum parameter on a small scale. we will understand the below parameters and will see how to modify them on the cluster level. 


PARAMETER DETAILS:

AUTOVACUUM_MAX_WORKERS : This parameter will show you how many Autovacuum process is working on cluster level.f there are four databases with autovacuum_max_workers set to 3, 

then, the 4th database has to wait until one of the existing worker process gets free.

AUTOVACUUM_VACUUM_THRESHOLD : The autovacuum_vacuum_threshold parameter controls the minimum number oftuple update or delete operations that must occur on a table before autovacuum vacuums it.

AUTOVACUUM_VACUUM_SCALE_FACTOR: The autovacuum_vacuum_scale_factor configuration parameter controls how aggressive theautovacuum process should be when vacuuming a table.

AUTOVACUUM_ANALYZE_THRESHOLD :  The autovacuum_analyze_scale_factor parameter controls how aggressive the autovacuum process should be when analyzing table.

AUTOVACUUM_VACUUM_COST_LIMIT: The autovacuum_vacuum_cost_limit parameter controls the amount of CPU and I/O resources that an autovacuum worker can consume.


how to work on parameter modification on cluster 

postgres=# show autovacuum_max_workers;
 autovacuum_max_workers
------------------------
 3
(1 row)

postgres=# show autovacuum_vacuum_threshold;
 autovacuum_vacuum_threshold
-----------------------------
 50
(1 row)

postgres=# show autovacuum_vacuum_scale_factor;
 autovacuum_vacuum_scale_factor
--------------------------------
 0.2
(1 row)

postgres=# show autovacuum_analyze_threshold;
 autovacuum_analyze_threshold
------------------------------
 50
(1 row)

postgres=# show autovacuum_vacuum_cost_limit;
 autovacuum_vacuum_cost_limit
------------------------------
 -1
(1 row)

postgres=#

[postgres@PG-V16 ~]$ cat  reset_the_par_values.sql

alter system set autovacuum_max_workers = 6;
alter system set autovacuum_vacuum_threshold = 100;
alter system set autovacuum_vacuum_scale_factor = 0.3;
alter system set autovacuum_analyze_threshold = 100;
alter system set autovacuum_vacuum_cost_limit = 100;
[postgres@PG-V16 ~]$


[postgres@PG-V16 ~]$ psql -p 5433 -d postgres -U postgres -f reset_the_par_values.sql
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
[postgres@PG-V16 ~]$ cat validate_vacuum_par_values.sql

show autovacuum_max_workers;
show autovacuum_vacuum_threshold ;
show autovacuum_vacuum_scale_factor ;
show autovacuum_analyze_threshold ;
show autovacuum_vacuum_cost_limit ;

[postgres@PG-V16 ~]$ psql -p 5433 -d postgres -U postgres -f validate_vacuum_par_values.sql
 autovacuum_max_workers
------------------------
 6
(1 row)

 autovacuum_vacuum_threshold
-----------------------------
 100
(1 row)

 autovacuum_vacuum_scale_factor
--------------------------------
 0.3
(1 row)

 autovacuum_analyze_threshold
------------------------------
 100
(1 row)

 autovacuum_vacuum_cost_limit
------------------------------
 100
(1 row)

[postgres@PG-V16 ~]$


ERROR: trailing junk after numeric literal at or near

 

Error : ERROR:  trailing junk after numeric literal at or near


Solution: Enter/specify the parameter value in "" 


Example: 

postgres=# show work_mem;

 work_mem

----------

 4MB

(1 row)


postgres=# set work_mem = 8MB;

ERROR:  trailing junk after numeric literal at or near "8M"

LINE 1: set work_mem = 8MB;

                       ^

postgres=# set work_mem = "8MB";

SET

postgres=# show work_mem;

 work_mem

----------

 8MB

(1 row)


postgres=#


Install and Configure 26AI Database on Linux

  Topic : Install and Configure 26AI Database on Linux   Deployment Diagram: In this QuickStart, we learn how to: Infrastructur...