Categories
Database

How to Change Passwords in MySQL Using 4 Methods?

Method 1: Using the SET PASSWORD Command Syntax: mysql> SET PASSWORD FOR username@localhost = PASSWORD('new_password'); Example: mysql> SET PASSWORD FOR root@localhost = PASSWORD('123'); Method 2: Using mysqladmin Syntax: mysqladmin -u username -p old_password password new_password Example: mysqladmin -uroot -p123456 password 123 Method 3: Directly Editing the user Table with UPDATE 1. Log in to MySQL. […]

Categories
Database

How to Quickly Recover Data After Accidental MySQL Operations

Almost every programmer working with databases (or perhaps your colleagues) will encounter this issue: how to quickly roll back after an accidental operation in MySQL? For example, deleting a table without adding a condition, resulting in the entire table being wiped out. If this happens in a production environment with critical business data, it could […]

Categories
Database

How to Display All Users in MySQL?

This is a common question asked by MySQL beginners. Today, let's explore how to display all users in MySQL. Typically, in MySQL, we use SHOW DATABASES to display all databases and SHOW TABLES to display all tables. So, you might assume the command to display all users is SHOW USERS, right? Nope, that's not the […]

Categories
Database

Principles of Hard Drives and How SQL Server Leverages Them to Reduce I/O

Hard Drive Principles Hard drives are the last mechanical storage component inside modern computers, operating at speeds significantly slower than memory or cache. However, due to their relatively low cost, they are well-suited for permanent storage. To mitigate the challenges posed by slower speeds, operating systems apply various optimizations. Let’s first understand the fundamental principles […]

Categories
Database

Differences Between MySQL and SQL Server

Differences Between MySQL and SQL Server MSSQL (SQL Server) originated as a product of collaboration between Sybase and Microsoft. For developers, the two most commonly used backend databases are currently MySQL and SQL Server. Their fundamental similarity lies in data storage and querying systems. You can use SQL to access data in both databases, as […]

Categories
Database

30 Tips for Database Optimization

30 Tips for Database Optimization 1. Optimize queries to avoid full table scans. Prioritize creating indexes on columns involved in WHERE and ORDER BY clauses. 2. Avoid checking for NULL values in the WHERE clause, as this will cause the engine to bypass indexes and perform a full table scan. For example: select id from […]

Categories
Database

What is an SQL Server Deadlock and What Causes It?

What is an SQL Server Deadlock? A deadlock is often confused with regular blocking. When a transaction requests a lock on a resource already locked by another transaction, the requesting transaction must wait until the lock is released. By default, SQL Server transactions do not time out unless LOCK_TIMEOUT is set. In such cases, the […]

Categories
Database

How to Check for Unreleased Cursors in SQL Server?

In our last post, we talked about how to obtain the start and end time of mysql binlogs. Toaday, let's see how to  check for unreleased cursors in SQL Server. I’ve never been particularly enthusiastic about using cursors in SQL Server and rarely use them. Recently, a user asked how to check for unreleased cursors […]

Categories
Database

How to Obtain the Start and End Time of MySQL Binlogs?

In our last post, we talked about how to check the storage engine of a table in MySQL. Toaday, let's see how to obtain the start and end time of mysql binlogs. When restoring a MySQL database to a specific point in time, we need to use a combination of a MySQL full backup, optional incremental backups, […]

Categories
Database

How to Check the Storage Engine of a Table in MySQL?

In our last post, we discussed how to check the Oracle client version on Windows/Linux. Today, let’s see how to check the storage engine of a table in MySQL. How can you check the storage engine of a single table in MySQL and how can you check which tables in an entire database use a […]