MariaDB: Verifying Deleted Users and Avoiding "Old User" Issues

2024-07-27

Here's what you can do to troubleshoot:

  • Check for Errors: Verify if there were any error messages when you tried to delete the user. This might give clues about why the deletion failed.
  • Try Logging In: Even though you think the user is still there, try logging in with the old username and password. If the deletion was successful, you should get an access denied error.
  • Verify User Table: If you're comfortable, you can directly check the mysql.user or mysql.global_priv table (depending on your MariaDB version) to see if the user is still listed.



Checking for Old Users in MariaDB

Checking for Login Errors (Doesn't directly check the table):

This code snippet attempts to login using the old username and password. If the deletion was successful, it will result in an access denied error.

-- Replace 'old_username' and 'old_password' with the actual values
SELECT 1 AS result
FROM mysql.user
WHERE User = 'old_username' AND Password = PASSWORD('old_password');

Note: This approach doesn't directly check the user table, but verifies deletion through login attempt.

Checking mysql.user table (For older MariaDB versions):

This code snippet queries the mysql.user table for the old username. If the user still exists, it will return a row.

SELECT *
FROM mysql.user
WHERE User = 'old_username';

Checking mysql.global_priv table (For MariaDB 10.4 and above):

This code snippet queries the mysql.global_priv table (relevant for MariaDB 10.4 and above) for the old username.

SELECT *
FROM mysql.global_priv
WHERE User = 'old_username';

Remember:

  • Replace old_username with the actual username you're trying to verify.
  • You might need appropriate privileges to access these tables.



  • Check for a table containing user login information, like user_login or a custom table you might have created.
  • Look for a field like last_login or last_access.
  • Users who haven't logged in for a long period (defined by your needs) could be considered "old."

Example (assuming a user_login table with last_login field):

SELECT username
FROM user_login
WHERE last_login < DATE_SUB(CURDATE(), INTERVAL N MONTH);  -- Replace N with desired timeframe in months

User Activity Logs:

  • If you have a system tracking user activity (e.g., application logs, database access logs), analyze those logs to identify inactive users.
  • Look for entries related to the old user and set a threshold for inactivity to classify them as "old."

User Roles and Permissions:

  • Review user roles and permissions. Users with unnecessary or outdated roles might be considered "old."
  • Identify roles that are no longer relevant and then check which users are assigned those roles.

User Information Updates:

  • Check for tables storing user information like profiles or settings. Look for timestamps related to the last update.
  • Users who haven't updated their information in a long time could be considered "old."
SELECT username
FROM user_profile
WHERE updated_at < DATE_SUB(CURDATE(), INTERVAL N MONTH);  -- Replace N with desired timeframe in months

mariadb



Understanding "Grant All Privileges on Database" in MySQL/MariaDB

In simple terms, "granting all privileges on a database" in MySQL or MariaDB means giving a user full control over that specific database...


MAMP with MariaDB: Configuration Options

Stands for Macintosh Apache MySQL PHP.It's a local development environment that bundles Apache web server, MySQL database server...


MySQL 5 vs 6 vs MariaDB: Choosing the Right Database Server

The original open-source relational database management system (RDBMS).Widely used and considered the industry standard...


Beyond Backups: Alternative Approaches to MySQL to MariaDB Migration

There are two main approaches depending on your comfort level:Complete Uninstall/Install:Stop the MySQL server. Uninstall MySQL...


MySQL vs MariaDB vs Percona Server vs Drizzle: Choosing the Right Database

Here's an analogy: Imagine MySQL is a popular recipe for a cake.MariaDB would be someone taking that recipe and making a very similar cake...



mariadb

Troubleshooting MySQL Error 1153: Got a packet bigger than 'max_allowed_packet' bytes

MySQL Error 1153: This specific error code indicates that the database server (MySQL or MariaDB) has rejected a data packet sent by the client (mysql or another tool) because the packet size exceeds the server's configured maximum allowed packet size


Speed Up Your Inserts: Multi-Row INSERT vs. Multiple Single INSERTs in MySQL/MariaDB

Reduced Overhead: Sending a single INSERT statement with multiple rows requires less network traffic compared to sending many individual INSERT statements


Understanding MySQL's SELECT * INTO OUTFILE LOCAL Statement

Functionality:This statement exports the results of a MySQL query to a plain text file on the server that's running the MySQL database


MariaDB for Commercial Use: Understanding Licensing and Support Options

Commercial License: Typically refers to a license where you pay a fee to use software for commercial purposes (selling a product that uses the software)


Fixing 'MariaDB Engine Won't Start' Error on Windows

MariaDB: An open-source relational database management system similar to MySQL.Windows: The operating system where MariaDB is installed