Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

โ€œInvest in yourself โ€” your confidence is always worth it.โ€

Explore Cosmetic Hospitals

Start your journey today โ€” compare options in one place.

Managing MariaDB Root Password and Connection Behavior in XAMPP (Ubuntu)


โ˜๏ธ Introduction

When working with MariaDB/MySQL inside XAMPP on Ubuntu, many developers face confusing issues related to root password behavior, localhost vs 127.0.0.1 access, and authentication plugins.
This tutorial provides a comprehensive step-by-step guide to understand, troubleshoot, and secure your MariaDB setup.

โœ… Learn why password prompts behave differently,
โœ… How to fix broken authentication (even after using --skip-grant-tables),
โœ… And how to set up proper security best practices for production or local development.


๐Ÿ›‘ Problem: Different Behavior Between localhost and 127.0.0.1

You may notice:

  • When connecting via localhost, MariaDB allows login without password.
  • When connecting via 127.0.0.1, it asks for root password.

โœ… This is not a bug โ€” it’s due to different connection methods.

Connection TypeBehavior
localhostConnects via Unix Socket (auth_socket plugin)
127.0.0.1Connects via TCP/IP (password-based plugin)

In MariaDB, different plugins can authenticate based on how you connect.


๐Ÿ” How to Check Current User Authentication Plugins

Login to MariaDB (even without password if allowed):

sudo mysql -u root

Run:

SELECT user, host, plugin FROM mysql.user;
Code language: CSS (css)

Typical result:

userhostplugin
rootlocalhostauth_socket
root127.0.0.1mysql_native_password

๐Ÿ›  How to Fix: Make Root Always Require Password

By default, in Ubuntu XAMPP, root@localhost may use auth_socket, meaning system login, not password login.
To fix and enforce password login, change the authentication plugin.

โœ… Correct command for MariaDB:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourStrongPassword';
FLUSH PRIVILEGES;
Code language: JavaScript (javascript)

โœ… After that:

  • Connecting via localhost or 127.0.0.1 both require password.
  • No automatic system user trust.

๐Ÿ›  What If You See --skip-grant-tables Error?

If you get:

ERROR 1290 (HY000): The MariaDB server is running with the --skip-grant-tables option
Code language: JavaScript (javascript)

It means:

  • Grant tables are disabled,
  • You cannot ALTER USER or SET PASSWORD.

โœ… Solution:

  1. Stop MariaDB:
sudo /opt/lampp/lampp stopmysql
  1. Start MariaDB normally:
sudo /opt/lampp/lampp startmysql
  1. Then login and fix password properly.

๐Ÿ“ฆ How to Check and Remove Permanent --skip-grant-tables

Sometimes, --skip-grant-tables is accidentally set in XAMPPโ€™s MariaDB configuration.

Check file:

sudo nano /opt/lampp/etc/my.cnf

Look for:

skip-grant-tables

โœ… If found, comment it out:

#skip-grant-tables
Code language: CSS (css)

โœ… Then restart MariaDB.


๐Ÿ”ฅ Best Practices to Secure MariaDB on Ubuntu (especially inside XAMPP)

PracticeWhy It Matters
Always set a strong password for rootPrevent unauthorized access
Disable root remote loginroot should only login from localhost
Create a new admin userUse adminuser@localhost for your apps instead of root
Keep your MariaDB updatedGet latest security patches
Secure XAMPP itselfPassword-protect XAMPP dashboard and phpMyAdmin

๐Ÿ›  How to Create a New Admin User (Recommended)

  1. Login:
mysql -u root -p
  1. Run:
CREATE USER 'adminuser'@'localhost' IDENTIFIED BY 'yourSecurePassword123!';
GRANT ALL PRIVILEGES ON *.* TO 'adminuser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Code language: JavaScript (javascript)

โœ… Now you can use adminuser safely for all database operations.


๐Ÿ“‹ Summary Checklist

ActionDone?
Fix root password with ALTER USERโœ…
Restart MariaDB without --skip-grant-tablesโœ…
Remove skip-grant-tables from my.cnfโœ…
Disable root remote access (optional)โœ…
Create separate admin user for appsโœ…

๐Ÿš€ Final Notes

  • When using MariaDB with XAMPP in Ubuntu, always verify connection method differences (localhost vs 127.0.0.1).
  • Ensure MariaDB server runs without –skip-grant-tables for full security.
  • Don’t use root for web apps โ€” create a limited user.
  • Always restart XAMPP cleanly after major database config changes.

๐Ÿง  Pro Tip

If youโ€™re planning to expose XAMPP or MariaDB over the internet (even in test environments):

  • Enable SSL/TLS for MySQL connections.
  • Use firewall rules to restrict IP access.
  • Prefer SSH tunnels for remote database connections instead of direct port opening.

๐Ÿ“ข Conclusion

“A secure database setup begins with understanding the basics: authentication, connection types, and privilege management.”

Following the steps in this tutorial will ensure you have a properly secured and consistent MariaDB environment inside XAMPP, ready for both development and production testing.

Stay secure. Happy coding! ๐Ÿš€


โœ… Ready-To-Use Final Command Set (Summary)

sudo /opt/lampp/lampp stopmysql
sudo nano /opt/lampp/etc/my.cnf   # Comment out skip-grant-tables if exists
sudo /opt/lampp/lampp startmysql

mysql -u root -p

ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourStrongPassword!';
FLUSH PRIVILEGES;

CREATE USER 'adminuser'@'localhost' IDENTIFIED BY 'yourSecurePassword123!';
GRANT ALL PRIVILEGES ON *.* TO 'adminuser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
Code language: PHP (php)

โœ… Done!

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
Iโ€™m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

The 5 Most Popular Email APIs Among Developers In 2026

In the modern world, where everything is going digital, email is among the most important means of communication both in personal and business life. As a developer,…

Read More

Top 10 Construction Management Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction Construction Management Software (CMS) has become indispensable in 2026 for efficiently handling various aspects of construction projects, ranging from budgeting, scheduling, resource allocation, project tracking, to…

Read More

Top 10 Loan Management Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction As the financial services sector continues to evolve, Loan Management Software (LMS) plays a pivotal role in helping businesses streamline their loan operations, from origination to…

Read More

Top 10 AI Presentation Design Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI presentation design tools have become indispensable for professionals, educators, and students aiming to create visually stunning and impactful slide decks with minimal effort….

Read More

Top 10 Web Design Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction Web design software is a vital tool for both professionals and businesses looking to create visually appealing and functional websites. In 2026, with the increase in…

Read More

Top 10 AI Graphic Design Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI graphic design tools have transformed the creative landscape, empowering designers, marketers, and business owners to produce stunning visuals with unprecedented speed and efficiency….

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x