HOME BLOG

Archive for September, 2022

How to fix error “my_config.h” file not found in MySQL-python on Mac OS

Posted on: September 30th, 2022 by Olu No Comments

Hi folks,

In this post I will briefly touch on how to fix the error that my_config.h could not be found when trying to install MySQL-python with pip on Mac OS 12.0.x with Python 2.7.x. We assume you installed MySQL via Homebrew.

The error looks like

    _mysql.c:44:10: fatal error: 'my_config.h' file not found
    #include "my_config.h"
             ^~~~~~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1

 

First, download my_config.h using commands:

cd ~/Downloads
curl https://raw.githubusercontent.com/jacob5412/MySQL-Medium/main/my_config.h -o my_config.h

 

Next, find your MySQL version by running command

mysql --version

Let’s assume your version is 8.0.29.

Make sure the following directory exists /usr/local/Cellar/mysql/8.0.29/include/mysql/.

Then copy the downloaded my_config.h into the directory using command:

cp my_config.h /usr/local/Cellar/mysql/8.0.29/include/mysql/

That’s it. You can now install MySQL-python using command:

pip install MySQL-python

That’s all for now. Till next time, happy software development.

References

Fixing “my_config.h” file not found in MySQL-python (Mac OS). https://medium.com/the-rising-tilde/fixing-my-config-h-file-not-found-in-mysql-python-mac-os-ff97663a8042.

How to be able to switch to another user without entering password

Posted on: September 17th, 2022 by Olu No Comments

Hi folks,

In this post I explain how to switch to another user in Linux without needing to enter a password.

You can do this with the PAM authentication module.

Edit /etc/pam.d/su

vim /etc/pam.d/su

 

Then enter the following lines

auth       [success=ignore default=1] pam_succeed_if.so user = the-username
auth       sufficient   pam_succeed_if.so use_uid user ingroup the-groupname

Save and exit the file.

This will allow you to switch to the-user if you belong to the-group without needing to enter the password for the user using a command like

 su - the-user

 

That’s all for now. Till next time, happy software engineering.

 

References

How to Switch (su) to Another User Account without Password. https://www.tecmint.com/switch-user-account-without-password/

How to use sudo command without password

Posted on: September 17th, 2022 by Olu No Comments

Hi folks,

in this post I discuss how you can use sudo command without password on a Linux system.

Back up your sudoers file

cp /etc/sudoers /etc/sudoers.old

Then, run visudo command

visudo

 

Then enter an entry like

your-user-name ALL=(ALL) NOPASSWD: ALL

 

Then, if visuo uses nano, press Ctrl X to save. Then press enter to finish the save.

Please note: it’s not good security pracrice to let a non-root user run sudo without passwords, so you may want to limit it to some specific commands.

That’s all for now. Till next time, happy software development.

 

References

How to Use sudo Commands Without Password in Linux. https://www.makeuseof.com/using-sudo-without-password/

Some interesting docker commands

Posted on: September 17th, 2022 by Olu No Comments

Hi folks,

Here I will talk about a few interesting commads  to know when working with Docker.

First, what is Docker? According to wikipedia, Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. The service has both free and premium tiers. The software that hosts the containers is called Docker Engine. It was first started in 2013 and is developed by Docker, Inc. Docker can package an application and its dependencies in a virtual container that can run on any Linux, Windows, or macOS computer. This enables the application to run in a variety of locations, such as on-premises, in public (see decentralized computing, distributed computing, and cloud computing) or private cloud. When running on Linux, Docker uses the resource isolation features of the Linux kernel (such as cgroups and kernel namespaces) and a union-capable file system (such as OverlayFS) to allow containers to run within a single Linux instance, avoiding the overhead of starting and maintaining virtual machines. Docker on macOS uses a Linux virtual machine to run the containers.

 

How to log in to a Docker artifacts repository

docker login -u someuser -p somepassword the-login-url

 

To build an image, you do

docker build -t name_of_container /path/to/directory-with-dockerfile/

To use a different docker file, you do

docker build -t name_of_container --file=name-of-docker-file /path/to/directory-with-dockerfile/

So, if you’re in the directory with the Dockerfile, just do

docker build -t name_of_container .

 

How to tag your image

docker tag your-image:latest the-repo-url/path/to/your/your-image:latest

 

How to push your image to a repository

docker push the-repo-url/path/to/your/image:latest

 

How to list Docker containers using command

docker ps

 

How to list Docker images using command

docker image ls

 

How to start a container for a particular image, making it run in the background and keeping it running indefinitely (in case it doesn’t already run that way)

docker run -d ubuntu tail -f /dev/null

If running a container with a particular name, e.g. ubuntu, indefinitely in the background, do the following:

docker run -d -t ubuntu

How to log into a container and have a shell (good for debugging)

docker exec -it mycontainername /bin/sh

 

How to kill a container

docker kill <container-id>

 

That’s all for now. Till next time, happy software development.

References

Docker (software). https://en.wikipedia.org/wiki/Docker_(software)