Sunday, June 8, 2025

Logging into MySQL Workbench as root for the first time (Jun 2025)

To See All Articles About Technology: Index of Lessons in Technology

The error in the screenshot means that MySQL Workbench (or a similar GUI tool) is unable to connect to your MySQL server using the root user at localhost:3306.

🔧 Cause:

The key issue is:

pgsql
Access denied for user 'root'@'localhost'

This means the root password is incorrect, or the root user is not allowed to log in via TCP/IP.


✅ Fix Steps

1. Make sure MySQL server is running

Run this in terminal:

bash
sudo systemctl status mysql

If it's not running, start it with:

bash
sudo systemctl start mysql

2. Try logging in from terminal

bash
sudo mysql -u root

If this logs you in without a password, then root is configured with auth_socket plugin.


3. Switch root to use password-based login (optional)

If you want to log in via Workbench, you'll need to allow password authentication:

sql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword'; FLUSH PRIVILEGES;

Then, test:

bash
mysql -u root -p

4. Use correct credentials in MySQL Workbench

  • Host: 127.0.0.1

  • Port: 3306

  • Username: root

  • Password: the one you set above

✅ Avoid using localhost — use 127.0.0.1 to force TCP/IP.


Let me know if you want to create a new MySQL user instead of changing root.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'pass';
Query OK, 0 rows affected (0.01 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye
(base) jain@jain-ThinkPad-T440s:~/Downloads$ mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

You're now getting:

vbnet
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

This error means MySQL server is not running, or the socket file is not available at /tmp/mysql.sock, which is where your client expects it.


✅ Step-by-Step Fix

1. Start MySQL Server

Run:

bash
sudo systemctl start mysql

If it gives:

System has not been booted with systemd as init system

You're likely on a system like MX Linux, which uses SysVinit or runit instead of systemd.

So try:

bash
sudo service mysql start

Then test:

bash
sudo service mysql status

2. Verify Socket Location (Optional)

Check where the MySQL socket is configured:

bash
mysqladmin variables | grep socket

Or:

bash
sudo cat /etc/mysql/my.cnf | grep socket

You might see:

perl
socket = /var/run/mysqld/mysqld.sock

If so, connect using:

bash
mysql -u root -p --socket=/var/run/mysqld/mysqld.sock

3. Reinstall or Repair MySQL (if needed)

If the server refuses to start, try reinstalling:

bash
sudo apt update sudo apt install --reinstall mysql-server

Let me know what you get when running:

bash
sudo service mysql start

Or share the output of:

bash
ps aux | grep mysqld
Tags: Technology,Database,

Saturday, June 7, 2025

The Power of Strategic Laziness - Working Smarter, Not Just Harder


All Book Summaries
In a world that often glorifies busyness and long hours, it's easy to fall into the trap of believing that the hardest workers are the most successful. But what if I told you that your perceived laziness could actually be your greatest asset? This isn't an excuse to do nothing; it's an invitation to embrace strategic laziness – a mindset that focuses your limited energy on what truly matters, avoiding unnecessary work and maximizing your impact.

Strategic laziness is about efficiency. It's the drive to find the path of least resistance to your goals, not by avoiding work altogether, but by avoiding inefficient or low-value tasks. Think about it: you have a finite amount of energy each day. How are you spending it? Are you constantly busy but struggling to point to significant accomplishments? This is the difference between activity and accomplishment. The ambitious but lazy person understands that energy is their most precious resource and directs it strategically.

Consider the Pareto Principle, also known as the 80/20 Rule. This principle suggests that roughly 80% of your results come from just 20% of your efforts. If you apply this to your work and life, it means a significant portion of your daily activities might be yielding minimal results. Strategic laziness encourages you to identify that high-impact 20% and ruthlessly eliminate or delegate the rest. Instead of trying to do everything better, focus on doing the most important things exceptionally well. This isn't about being sloppy; it's about being smart with your time and energy.

Another key aspect is decision minimization. Every decision, no matter how small, drains your mental energy. Decision fatigue can silently sabotage your productivity, leaving you with less capacity for important tasks later in the day. By creating decision frameworks, templates, and defaults for recurring situations, you free up valuable mental bandwidth for creative work and high-leverage thinking. Simple strategies like having a default schedule, setting personal policies (e.g., no meetings before a certain time), or simplifying daily choices like meals and clothing can make a significant difference.

Environment design also plays a crucial role. Your environment often has a stronger influence on your behavior than willpower alone. Instead of relying solely on discipline, design your physical, digital, and social environments to make good choices the easy choices and bad choices more difficult. Want to reduce distractions? Put your phone in another room while you work. Need to exercise more? Lay out your workout clothes the night before. By reducing friction for desired behaviors and increasing friction for undesired ones, you create a system that supports your goals automatically.

Strategic automation is another powerful tool for the strategically lazy. Why repeat tasks manually when you can set up systems to do them for you? Identifying recurring tasks and automating them frees up your time and energy for more valuable activities. This could involve using email templates, scheduling social media posts, setting up automatic bill payments, or creating standard operating procedures for repeated processes. The initial investment in automation pays dividends over time, allowing you to scale your impact without increasing your effort proportionally.

Ultimately, strategic laziness is about building systems, not just setting goals. Goals can be motivating, but they often focus on future outcomes without providing a clear roadmap for present action. Systems, on the other hand, are processes that operate in the present and consistently move you forward. Instead of setting a goal to write a book, create a system where you write a certain number of words each day. By focusing on building robust systems, you make success almost inevitable, regardless of your motivation on any given day.

Finally, embrace the concept of the Minimum Effective Dose (MED). This is the smallest amount of effort needed to produce the desired outcome. Anything beyond the MED is wasted effort. Whether it's in fitness, learning, or business, finding the MED allows you to achieve maximum results with minimal input. It's about identifying the leverage points where your effort has the greatest impact and stopping when you've achieved the desired result, rather than continuing to work for diminishing returns.

By adopting a mindset of strategic laziness, you can move beyond simply working hard and start working smarter. It's about being intentional with your energy, focusing on high-impact activities, minimizing unnecessary decisions, designing supportive environments, leveraging automation, building effective systems, and finding the minimum effective dose in everything you do. So, the next time you feel a pang of guilt about not being constantly busy, remember that strategic laziness might just be the key to unlocking your greatest potential.
Tags: Motivation,Video,

Wednesday, June 4, 2025

Remember Death (Memento Mori)


All Book Summaries
'''# Remember Death, Embrace Life: Finding Purpose in Mortality
"I've got bad news. You're going to die." It’s a blunt statement, perhaps unsettling, but undeniably true. Every single one of us shares this ultimate fate. While medical advancements have extended lifespans remarkably, the mortality rate stubbornly remains at 100%. This isn't meant to be morbid; rather, it's a profound truth that holds the key to living a more vibrant, focused, and meaningful life. The ancient Romans had a phrase for this: Memento Mori – remember death. Far from being a depressing mantra, this reminder can be a powerful catalyst for change, urging us to ask not when we will die, but how we will live in the time we have.
Throughout history, confronting mortality wasn't always as sanitized or distant as it often is today. Consider the French nobleman Michel de Montaigne. A near-fatal riding accident in 1569 fundamentally altered his perspective. Lying broken, life "dancing on the tip of his lips," he survived, but the experience energized him. He transformed from an aimless drifter into the inventor of the essay, a celebrated writer, diplomat, and mayor. His brush with death became his turning point. This echoes countless stories – the cancer diagnosis that sparks a new passion, the near-miss that mends relationships. History is filled with reminders: vanitas paintings featuring skulls alongside flowers and hourglasses, symbolizing the transient nature of life; the stark danse macabre art depicting skeletons mingling with the living; even cadaver tombs bluntly showing the reality of decay with inscriptions like, "What I am, soon you will be." These weren't meant to induce fear, but to foster appreciation for the present.
Perhaps no philosophy embraced memento mori as practically as Stoicism. Ancient Stoics – emperors like Marcus Aurelius, playwrights like Seneca, former slaves like Epictetus – weren't academics idly pondering mortality. They were people engaged in the world, using the awareness of death not as an abstract concept, but as a tool for living well. They weren't obsessed with death; they were obsessed with life. Seneca urged us to see that death isn't just a future event, but something happening now. "The time that’s passed is owned by death," he wrote. We die daily, minute by minute. This perspective highlights the irreplaceability of time – a resource we often squander while fiercely guarding less valuable assets like money or property. Marcus Aurelius, writing his Meditations perhaps not far from modern-day Budapest, posed a challenging question: "Stop whatever you’re doing... ask yourself, ‘Am I afraid of death because I won’t be able to do this anymore?’" He forces us to confront whether we cling to life for trivial pursuits – endless scrolling, meaningless arguments, procrastination – or for genuine, purposeful living. Wasting precious life on things that don't matter is, in Seneca's blunt words, a kind of living death.
In our modern world, death is often hidden away, discussed in hushed tones. This distance can make us forget its inevitability and, consequently, the preciousness of life. Yet, the Stoic exercises remain profoundly relevant. Epictetus offered a stark, perhaps controversial, practice: "As you kiss your child goodnight, whisper to yourself, ‘He may be dead in the morning.’" The point isn't to dwell on potential tragedy, but to cultivate profound presence and appreciation for the moments we have now. It combats the tendency to rush through life, always chasing the next thing, forgetting to cherish the people and experiences right in front of us. What are we rushing towards? Death. Remembering this helps us slow down, prioritize, and connect. It cuts through the noise of trivial anxieties and focuses the mind on what truly matters – relationships, purpose, contribution, being present.
The bad news – our inevitable mortality – paradoxically contains the best news: knowing our time is finite gives us the choice, right now, to live with intention. Memento mori isn't a call to despair, but an invitation to wake up. It’s a tool to cut through procrastination, fear, and triviality. By confronting the one certainty we all face, we can find clarity, focus, and an energizing appreciation for the incredible, fragile gift of life. Don't wait for a near-death experience to start living. Remember death, and in doing so, truly learn to live. How will you use this knowledge today?
Tags: Motivation,Video

Tuesday, June 3, 2025

What Actually Matters in Your 30s


All Book Summaries

Forget the Checklists. Focus on What Compounds.

Your 20s are a decade of chasing: titles, milestones, aesthetics. You’re busy collecting highlights that look good from the outside. But when you hit your 30s, the game changes. Quietly, but profoundly.

This isn’t a time to keep checking boxes — it’s a time to build foundations. Because what you build now, while you still have energy, curiosity, and time on your side, will echo through every decade that follows. Compound interest doesn’t just apply to money. It applies to habits, relationships, health, and choices.

The biggest mistake most people make? Optimizing for the wrong things. Climbing ladders leaning against walls they never meant to scale. Spending their best years chasing things that won’t matter five years from now — let alone 50.

So what does matter?

Financial habits that compound.
It’s not about getting rich. It’s about giving your future self options. Start investing. Automate your savings. Understand the cost of delay. Every dollar you invest in your 30s could be worth 10x in retirement. Your greatest financial asset isn’t a high-return stock — it’s time.

Career choices with long-term alignment.
Stop chasing titles. Start chasing fulfillment. Take risks while you still have room to recover. Define success on your terms. Ask: Are you growing? Are you building skills that compound? Is your work aligned with your values?

Relationships that nourish.
Your 30s are for curating, not collecting. Choose people who make your life feel fuller. Deepen your friendships. Invest in your partner. Spend more time with those who truly matter — and less with your feed.

Health habits that last.
Your 20s let you get away with everything. Your 30s start keeping score. Focus on sleep. Move daily. Manage your mental health before burnout hits. Small habits, repeated daily, will do more than any 30-day transformation.

Mindsets that evolve.
Let go of perfection. Embrace growth. Say no more often. Choose depth over distraction. Trade hustle for intentionality. Your 30s aren’t about being flawless — they’re about being real and resilient.

The throughline? Integration. Each part — money, career, relationships, health — affects the others. Strength in one area gives you flexibility in the others. Your 30s are a decade of strategic investment in the person you’re becoming.

The real question isn’t am I behind?
It’s: Am I building something I’ll be proud of when I’m 80?

Because that’s what actually matters.

Tags: Book Summary,Video,Psychology,

Monday, June 2, 2025

Discussion on 'Count Divisors' (Problem from Hacker Earth)

To See All Articles About Technology: Index of Lessons in Technology

Try it out
Problem

You have been given 3 integers: l, r and k. Find how many numbers between l and r (both inclusive) are divisible by k. You do not need to print these numbers, you just have to find their count.

Input Format
The first and only line of input contains 3 space separated integers l, r and k.

Output Format
Print the required answer on a single line.

Constraints
1 <= l <= r <= 1000

1 <= k <= 1000

Sample Input
1 10 1
Sample Output
10

Time Limit: 1
Memory Limit: 256
Source Limit:

Psuedocode

if (r - l + 1) > k return (r - l + 1) / k else: if floor(l / k) == floor(r / k): return 0 else: return 1 Critique this psuedocode.

Solution


Your pseudocode is heading in the right direction by trying to find how many numbers in the range [l, r] are divisible by k, but it still contains logical issues. Let’s break it down carefully and critique each part:

Goal
We want to count all numbers x such that l ≤ x ≤ r and x % k == 0.

 Issues in Your Pseudocode
Your pseudocode:

if (r - l + 1) > k
    return (r - l + 1) / k
else:
    if floor(l / k) == floor(r / k):
        return 0
    else:
        return 1

Problem 1: (r - l + 1) / k doesn't count multiples of k
This gives the average number of elements between l and r per k steps, not how many elements are divisible by k.

Consider l = 3, r = 10, k = 2

r - l + 1 = 8

8 / 2 = 4 ✅ correct here by luck

But try l = 5, r = 15, k = 3:

r - l + 1 = 11, 11 / 3 = 3 ❌ wrong (actual count: 4 → 6, 9, 12, 15)

🔴 Problem 2: Your else block logic is oversimplified
plaintext
Copy
Edit
if floor(l / k) == floor(r / k):
    return 0
else:
    return 1
This assumes that at most one number divisible by k exists in [l, r], which is incorrect.

For example, l = 3, r = 10, k = 2:

floor(3/2) = 1, floor(10/2) = 5 → not equal → returns 1 ❌ but actual count is 4

✅ Correct and Simple Pseudocode

Input: l, r, k

# Use integer division (i.e., floor)
count = floor(r / k) - floor((l - 1) / k)

Return count
✅ Why this Works
Let’s take l = 5, r = 15, k = 3

Numbers ≤ 15 divisible by 3: 3, 6, 9, 12, 15 → total = floor(15/3) = 5

Numbers ≤ 4 divisible by 3: 3 → total = floor(4/3) = 1

So numbers divisible by 3 in [5, 15] = 5 - 1 = 4

💡 Final Thoughts
❌ Avoid using (r - l + 1) / k unless l = 1 and k = 1

✅ Stick to the formula floor(r / k) - floor((l - 1) / k) for correct results in all ranges

Would you like a Python function implementing this pseudocode too?
    

Explanation

✅ Correct Way to Count Multiples of k in [l, r] The correct formula is: count = floor(r / k) - floor((l - 1) / k) It works because: floor(r / k) counts how many numbers from 1 to r are divisible by k floor((l - 1) / k) counts how many from 1 to l-1 are divisible by k Subtracting the two gives how many are in the range [l, r]