Home » Articles posted by Michael

Author Archives: Michael

ClamAV: “libfreshclam init failed, Initialization error!”


Basic Information

ClamAV is a stable anti virus software for Linux and it is available since two decades. Viruses could be an issue on Linux systems but it is more likely to get a rootkit infection on a Linux system. Basically it is not a failure to have an anti virus software on a Linux computer, for example to check downloaded files.

It could also make sense to install ClamAV to scan a Samba file share for Windows clients which is provided on a Linux server.

ClamAV is easy to install and it is available in the repositories of the most distributions.


The Installation

First of all we need to install ClamAV (here on Ubuntu) with this command:

apt-get install clamav

As a next step we need to update the virus definitions. But this could lead us to an error:



The Problem and the Fix

The update of the anti virus definitions can be done with this command:

freshclam

But on several systems I got this message here:

ERROR: /var/log/clamav/freshclam.log is locked by another process
ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).
ERROR: initialize: libfreshclam init failed.
ERROR: Initialization error!

The problem is that “freshclam” locks a file (/var/log/clamav/freshclam.log) and does automatically updates in the background. This is just fine, but if we want to get debugging information of the anti virus definition update procedure we need to run these commands:



We need to find the PID of “freshclam” with the “ps -ef” command and then we need to stop it with the “kill” command. (Here is the PID of the “freshclam -d” process 1281)

The command “kill -p PID” stops the lock of the file “/var/log/clamav/freshclam.log” and then “freshclam” can be executed.

We see several times the message “up-to-date” in the last lines on the picture.


Conclusion

ClamAV is a kind of dinosaur in the Linux world. Its is uncomplicated and works well on Linux. The update procedure of the anti virus definitions can cause an error and the automatic update feature needs to be stopped. After stopping the automatic updates a manual update can be done.

Feel free to comment my blog post.

Automount ZFS RAID on Debian 11

computer screen with code


ZFS is a modern file system with a lot of cool features, like encryption, handling very big volumes, providing data integrity (bit rot prevention) and high performance. Originally ZFS was developed by Sun Microsystems for Solaris and a Linux version of ZFS is available since 2013.

On systems with ECC RAM memory ZFS shows its advantages in terms of data integrity.

Another benefit is that ZFS combines several features like disk redundancy and encryption among other features in one single technology. As well it is possible to send encrypted volumes through a network for backup purposes.


The Problem

The problem is that auto mounting the ZFS volume could fail if the system is badly configured.

We will generate a key file which should be stored on a LUKS encrypted volume. If the server starts up, the ZFS volume should be mounted automatically. Let me show you how I did it:


The Fix

First of all we need to install ZFS with apt-get:

apt-get install zfsutils

As next step we need to create a key file for the encryption. Keep this file in a secure place like a LUKS volume on the server and have a copy on another secure storage:

dd if=/dev/random of=/root/zfs-encryption.key bs=1 count=32

Next we create a Zpool. We create a Raidz also known as Raid5.

zpool create -f tank1 -o - ashift=12 -o feature@encryption=enabled -O encryption=on -O keylocation=file:///root/zfs-encryption.key -O keyformat=raw raidz /dev/disk/by-id/wwndisk1 /dev/disk/by-id/wwndisk2 /dev/disk/by-id/wwndisk3 /dev/disk/by-id/wwndisk4

After creating the RAID which contains the disks we need to create a ZFS file system:

zfs create -o mountpoint=/tank1/zfs tank1/zfs

Next we need to create a Systemd startup script for ZFS by opening the file /etc/systemd/system/zfs-load-key.service. Add this code to the file:

[Unit]
Description=Load encryption keys
DefaultDependencies=no
Before=zfs-mount.service
After=zfs-import.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/bash -c '/usr/bin/zfs load-key -a'

[Install]
WantedBy=zfs-mount.service

Now we need to enable the service to start during the system startup:

systemctl enable zfs-load-key.service

Now reboot the system and ZFS should be mounted automatically.


Conclusion

ZFS is a feature rich modern file system. Auto mount a ZFS volume could be a small challenge. I showed you how to automatically mount a ZFS volume on Debian 11. Keep the decryption key file always safe and keep a backup of it.

Feel free to write a comment and have fun!

Install and Configure Security Software on Ubuntu

security as text and a mouse cursor

Introduction

The topic of the blog post is applied IT Security on Linux Ubuntu Desktops. IT security is a hot topic since all the aspects of our live is based on IT in one form or another. Many companies around the world are affected by attacks against their IT systems and these attacks do a huge harm and cost a lot of money.

On one side systems and data security is a challenge for companies but on the other side also private individuals are seeking for security and want to have safe IT systems.

Ubuntu Desktop and Linux Desktop users are less exposed to cyber threads than Windows users but Microsoft also geared up its recent Windows versions regarding to IT security.

From my experience I can say that mostly an odd behavior of a Linux desktop system is caused by a software bug rather than a hacker, a virus, a rootkit or another malware. That applies to Windows too.

But to be sure it’s always good to know how to check your Ubuntu PC or Linux Desktop for malware and keep it safe. That’s why I want to introduce 4 Linux IT security tools to you. They are:

  • Rookit Hunter which is a malware scanner
  • ClamAV, an anti virus software
  • Chkrootkit, another malware scanner
  • UFW, stands for uncomplicated firewall

Let’s start with Rootkit Hunter:


Rootkit Hunter

A rootkit is a malicious software which grants a hacker full access to an IT System. There are a lot of different rootkits around for Linux systems.

There is a software for detecting rootkits on Linux systems which is called Rootkit Hunter.

First of all, if we want to use Rootkit Hunter, we need to install it by opening a terminal and and we need to execute:

sudo apt-get install rkhunter

As a next step we need to update Rootkit Hunter:

sudo rkhunter --update

Then we have to do a check of our Linux (Ubuntu) system with:

sudo rkhunter -c

Several checks are done then on the Linux system.

Often Rootkit Hunter doesn’t run immediately after the installation and gives us some errors.

Learn here how to fix WEB_CMD, Update failed, SCRIPTWHITELIST errors.

We learn about a Linux anti virus software next.


ClamAV

ClamAV is the Linux anti virus software which is available since more than two decades. There are every now and then proprietary anti virus solutions for Linux popping up for a short period of time. I have seen Linux versions from the anti virus software vendors Sophos, AVG, Avira and so on. But after so short time these products were vanishing.

So ClamAV is the most reliable anti virus software for Linux. Let’s learn how to install it on Ubuntu:

sudo apt-get install clamav

Next we need to update the virus definitions:

sudo freshclam

Then we are able to scan a directory with the following command and its options:

clamscan /home –recursive=yes –infected

The parameter “–recursive” means that also sub directories of /home are scanned. The option ” –infected” means that there is only output in the terminal if a virus was found. /home is our directory which we want to be scanned.

So far, so good. Now we are learning about another rootkit scanner – Chkrootkit.


Chkrootkit

Chkrootkit is like Rootkit Hunter a detection software for rootkits on Linux systems.

Since rootkits are often hiding themselves on infected system it could be a good approach to scan the system (the file system) with a Linux live system. Find the instruction here!

The first step is to install Chkrootkit on Ubuntu:

sudo apt-get install chkrootkit

Then do the check with:

sudo chkrootkit 

Here you are seeing if there are finds or suspicious files on the computer. As next we learn about a firewall.


UFW – Uncomplicated Firewall

Not only scanning a system and detecting malicious software is important for systems and data security. Also protecting our services on our Linux system with a firewall is an important prevention and security measure.

Depending on our systems setup probably several services (servers, also called daemons ) are active on our Linux. It could be the SSH server (Secure Shell Server) or any other service. We want to protect these services with a firewall.

The most firewall products need a deeper understanding of networking and networking technologies. But there is a simple solution available for Linux called “UFW – Uncomplicated Firewall”. If installed and activated it blocks incoming network traffic by default and allows all the outgoing network traffic.

Let’s install UFW with “apt-get”:

sudo apt-get install ufw

Then we need to enable the UFW with:

sudo ufw enable

To get more detailed information type:

ufw status verbose

You will see these lines in the output:

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

Conclusion

I introduced 4 important tools to you and I showed you how to install and configure these tools. The rootkit scanners are a good starting point if a systems show an odd or suspicious behavior. And ClamAV is a stable project since many years. It’s always good to have a firewall enabled and UFW is really easy to enable and to handle.

Feel free to comment this post!

Fix Rootkit Hunter Errors: WEB_CMD and “Update failed”

the text security and a mouse cursor

Introduction

IT Security is an important topic nowadays. Since every aspect of our daily life is affected by IT, systems security and data security became essential. Hackers penetrate companies and their IT system all around the world day by day.

Also Linux can be compromised by hackers. Although Windows is still dominant on desktops and laptops and therefore it was the main target for hackers in the past, Linux has its high market shares in the servers sector and as well at the mobile devices market .

Windows systems were mainly affected by classical viruses in the past, while Linux desktops and Linux servers where more exposed to rootkits. A rootkit is a malicious software which grants full access, known as root access, to a hacker on a compromised system.

Rootkits are difficult to detect but there is software available which can give a first hint of compromise to a systems maintainer.

Among a few open source tools there is Rootkit Hunter available to scan Linux systems. But by default it can be misconfigured and some fixes need to be done:


The Problems and their Fixes

First of all the installation of Rootkit Hunter needs to be done. I show here the installation and the fixes on a Ubuntu Desktop. The command for the installation is :

sudo apt-get install rkhunter

As a next step we want to update the rootkit definitions similar to anti virus definitions:

sudo rkhunter --update

And then we are getting this error message:

Invalid WEB_CMD configuration option: Relative pathname: "/bin/false"

Here is a screen shot with of the problem:



…and as well we see the fix for the problem in the last line of the screen shot. Here is the command to copy for you:

sudo sed -i 's/WEB_CMD=\"\/bin\/false\"/WEB_CMD=\"\"/g' /etc/rkhunter.conf

But that’s not all! As we continue another error appears, if we run “sudo rkhunter –update” again. The output is “Update failed”. But there is also a fix as you see next:


terminal output update failed

The fix for the problem as bash command:

sudo sed -i 's/UPDATE_MIRRORS=0/UPDATE_MIRRORS=1/g' /etc/rkhunter.conf
sudo sed -i 's/MIRRORS_MODE=1/MIRRORS_MODE=0"\"/g' /etc/rkhunter.conf

Next we see that the command finally works:



But then another error appears if we want to ran a scan. The command for the scan is:

sudo rkunter -c

Here is the error message:

Invalid SCRIPTWHITELIST configuration option: Non-existent pathname: /usr/bin/egrep

Invalid SCRIPTWHITELIST configuration option: Non-existent pathname: /usr/bin/fgrep

Here is the screen shot of the probĺem:


terminal and sed command

And as well the fix is here as code:

sudo sed -i 's/\/usr\/bin\/egrep/\/bin\/egrep/g' /etc/rkhunter.conf

sudo sed -i 's/\/usr\/bin\/fgrep/\/bin\/fgrep/g' /etc/rkhunter.conf

After these modifications our rootkit check finally worked as you see here:


terminal rauth rkhunter check

Conculsion

Rootkit Hunter is a good piece of software but on some Ubuntu version it fails if it is executed after the installation. The procedures here make Rootkit Hunter functioning properly. As well I showed how to fix a problem with updating Rootkit Hunter.

Feel free to comment my blog post!

Block Brute-Force Attacks against WordPress

hand types on keyboard in the dark

Introduction

WordPress is a Content Management System (CMS) and blogging software which allows one to publish content in the internet. Many web pages in the internet are built on the popular WordPress software.

WordPress consists mainly in HTML and PHP Code and stores its data in a SQL database like MySQL or MariaDB.

Like all other IT systems WordPress based web pages can be under attack by hackers. Basically any computer or device in the whole internet can start an attack to a public web page. There are different kinds of attacks but one very often used approach to try to get access to an IT system is password guessing. The technical term for password guessing is brute-force attack.

The strategy of the attackers is to try a lot of different passwords over and over again. After a short analysis of the WordPress page the active users are identified by the attacker. If an active user account is identified, a lot of passwords are tried out. These attacks are done automatically by scripts.

If weak and short password are used for our WordPress page they could be easily guessed. That’s why always use super long and super strong password consisting in numbers, lowercase letters, capital letters and symbols. 16 position or longer passwords are recommended.

The problem of these attacks is that they are often undetected. The password guessing can take days, weeks or months and nothing prevents this if WordPress is not protected.

A good piece of software which protects us from these kind of attacks is “GuardGiant Brute Force Protection”. It’s a WordPress plugin and it is free. Let me introduce this software to you. First of all we need to install it.


Installation of GuardGiant Brute Force Protection

Like any other WordPress plugin we need to install it through the Dashboard of our WordPress page. Search for the plugin by its name. It looks like this:


wordpress brute force protection plugin installation page

Click on “Install Now” and then to “Activate”.


Settings and Configuration

The predefined settings are already fine to protect us. As you see there is distinguished between “Limit Login Attempts On User Account” and “Block IP Addresses Making Multiple Failed Login Attempts”.



This means that if an existing user account is penetrated, this user account will be locked for 2 minutes after 10 wrong passwords are tried. As you see after 8 failed login attempts form a single IP address, from this IP cannot be logged anymore in for 4 minutes.

Important: These setting could lock us out from our WordPress page, if a valid user account is denied from logging in!

That’s why we need to whitelist our IP address, so that our computer is always allowed to log in, no matter how may failed login attempts are done from our computer!


whitelist setting of the plugin

As you see above two IP addresses are whitelisted and they are never affected or locked by the plugin.

Another options which cover up the existence of an existing user you see here:



By default WordPress tells the one who wants to log in if there is a failure in the user name spelling or if just the password is wrong. The option above covers this.

Additionally: Always keep WordPress, its themes and plugins up to date to reduce the probability to be a victim of hackers.


Conclustion

I recommend this plugin because it prevents password guessing attacks. The plugin is easy to configure and the predefined settings make sense. Don’t forget to whitelist your own IP address, so that you are note locked out.

If you observe your WordPress logs you will see that this plugin does its work by reducing the login attempts by unauthorized devices.

Feel free to comment my post and have fun with WordPress and its plugins. 🙂

8 Free and Important WordPress Plugins (2023)

scrabble letters saying blog

Introduction

WordPress is a popular blogging and Content Management System (CMS) software. It is used to publish blogging content to the internet or as a base system for web pages. Other widespread CMS software is Joomla! or Drupal. These systems exist since many years and over the time theses systems became very similar to each other.

Learn here how to install WordPress. Here is an instruction how to install CMSimple which is another ascending CMS software!

WordPress can be considered as a construction kit with many modules. The basic design is called “theme”. The theme consists in font styles, color schemas, graphical elements, menus and so on.

Plugins on the other hand are modules which are providing not a design but a functionality – like a backup function, a contact form, translations, compliant functions or security improvements.

Themes and plugins are mostly and basically free of costs, but advanced functions can cost money. WordPress itself is free as well.

In this article we will learn which free plugins support us to develop a professional WordPress page. We are starting with a backup plugin.


1. Backup Migration (by Migrate)

The topic backup is ubiquitous in IT. A data backup means that there is in the case of data loss a copy of the lost data, so that the original status of the system can be restored.

In our case, when we develop and maintain a WordPress page, changes happen during the time. Content changes and updates are installed constantly. I the case of a failure, it can be a hacking, a server failure or a maintenance mistake, with a backup the system can be restored.

I recommend “Backup Migration” by Migrate.


user interface of the software backup and migration

The handling is quite intuitive. Manual and automatic backups can be done and backups can be downloaded. There is a special feature called “migration”. A migration of a web page to a new domain or a new server can be done easily.

The data restore in a case of failure can be done easily as well.


2. Disable and Remove Google Fonts (by Fonts Plugin)

Nowadays it is important to have a “General Data Protection Regulation” (GDPR) compliant web page to not catch a juristic case.

In 2022 people were sued because their web site connected to the Google servers to use Google’s fonts. Google got the IP address of the web site visitors and could track the visitors behavior without their consent. This caused juristic troubles to web site owners. WordPress doesn’t suppress this behavior by default.

A plugin is necessary to stop WordPress connecting to Google’s servers.

The plugin has the name “Disable and Remove Google Fonts” by Fonts Plugin:


red rectangle with white cross, logo of disable google fonts plugin

The plugin just needs to be installed and it then provides its function. I will continue with the topic security because it’s important next to the GDPR compliance.


3. Sucuri Security – Auditing, Malware Scanner and Security Hardening (by Sucuri Inc.)

IT systems and data security is a very important topic and integrity, confidentiality and availability of the data and the systems is the aim.

To protect our web page against hackers additional security is desirable. The plugin “Sucuri Security – Auditing, Malware Scanner and Security Hardening” by Sucuri Inc. does a good job in securing our web page.

The free version’s features are security logging, integrity scanning, web page hardening and notification services.


sucuri graphical user interface, buttons and settings

An alternative to the Sucuri Inc. plugin is “Wordfence Security – Firewall & Malware Scan” by Wordfence. On some of my web pages I am using Wordfence on others the Sucuri Inc. plugin.

The next plugin affects the ranking on the Google result page.


4. Yoast SEO (by Team Yoast)

If a web page is designed mostly it should have a good ranking in the Google result page. The technical term is “Search Engine Optimization” (SEO). Since money is invested and money should be made with web pages clients want to be ranked well in Google.

The free version of the Yoast SEO plugin gives hints and feedback about the structure of the content of the web page. It analyzes the structure of the text and gives hints about key words and meta descriptions of the web page and sub pages.


SEO readability red and green dots

As you see in the image feedback by Yoast is given about the SEO and readability of the text.

The next topic is about statistics.


5. WP Statistics (by VeronaLabs)

WP Statistics is a GDPR compliant alternative to “MonsterInsights – Google Analytics”. Google Analytics could cause juristic trouble and a worry free alternative is WP Statistics. For sure the free version is very limited compared to Google Analytics.

WP Statictics shows details like the visitors browser, the country of origin and visitors and visits are distinguished and counted.

The plugin shows popular sub pages and dates and time of the visits as well as the visitors operating system.

It is important to get the Key Performance Indicators (KPIs) an statistics of your web page, so that you can optimize the content and measure your success.


list of browser logos, country flags, dates, operating system names

A clear and handy alternative with a focus on privacy too is “Burst Statistics – Privacy-Friendly Analytics for WordPress” by Really Simple Plugins.

Nowadays it is all about GDPR, privacy and compliance and the next plugin is another building block to stay on the safe side.


6. Real Cookie Banner: GDPR (DSGVO) & ePrivacy Cookie Consent (by devowl.io)

Cookies are small files and they are stored by web pages to the visitors computers and cookies can be used to track visitors. Visitors need to have chance by law to deny the set of cookies on their computers.

Real Cookie Banner is a cookie banner which really prevents the set of the cookies on the visitors computer if he or she denies it by clicking on the “deny” button. I tested it and it works. The only disadvantage of the free version is the fact that it doesn’t cover Google AdSense cookies.

For Google AdSense to be covered the Pro version is needed instead which takes money. The plugin scans the whole web page and detects all the cookie setting code automatically. After the scan an appropriate banner is created and later on served to the web page visitors.

Depending on the setup of the web page a proper functioning cookie banners can be mandatory for your web page. It is very obvious if there is a cookie banner when one enters the web page or there is no cookie banner popping up.

Ask your lawyer to check your web page for its GDPR and privacy compliance.


user interface of cookie banner, setting and scanner button, switches

Because GDPR compliance is an important topic another plugin helps to protect you and your web page.


7. Disable Emojis (GDPR friendly, by devowl.io)

Emojis are small symbols which are enriching the text and content of your webpage. These little smiles can have an impact to the visitors privacy because they are sometimes downloaded from another domain. IP addresses are then transferred to this domain and this causes a violation of the visitors privacy.

To prevent the violation of the visitors privacy just install “Disable Emojis (GDPR friendly)” by devowl.io. You don’t have to do additional configurations and the text enriching Emojis will still work.

Okay, it’s enough now about compliance. Let’s talk about the web page performance at the last point.


8. WP Super Cache (by Automattic)

Let’s speed up our page. The “WP Super Cache” plugin loads the bulky WordPress PHP files in advance and converts them into HTML, which is then served to the visitors computers. This improves the loading times of the web page.

Just install the plugin and activate it. A new menu entry appears in the WordPress Dashboard.

As you see in the screen shot there is an easy mode for quick configuration and no special configuration is needed:


super cache settings, easy mode, caching on is selected


Conclusion

In my role as web developer I nearly always install the plugins listed above. I can recommend you to do so if you want stay compliant, secure and performant with your web page.

Depending on your projects requirements other plugins for sure can be necessary as well. Feel free to give a comment to this post.

Windows 10 slow on older Hardware

computer keyboard

Basic Information

Windows 10 is also in 2023 a popular and widely used operating system. Although Windows 11 is released since 2021 Windows 10 is still current. Windows 10 will be supplied with security updates until October 2025. Until this time Windows 10 can be used safely without any disadvantage.

The situation is different for Windows 8.1 and for sure for Windows 7. These systems are “end of life” (EOL) and should not be used anymore becauase of a lack of system security. Also an Anti Virus Software doesn’t compensate that there are no security updates offered by Microsoft anymore.

Windows 10 can also be installed and running on older Hardware. Microsoft writes that Windows 10 is able to be functioning on devices with at lease 2 GB of RAM and a 1 GHz processor (CPU). These low system requirements tempt to install Windows 10 on older hardware.

But to not be disappointed by the low performance a trick needs to be done.


The Problem

If you installed Windows 10 on weaker hardware the slow speed of the system and reduced usability could be an issue. The reaction to a click could take up to a few seconds and this can be very annoying if you want to work efficient and effective.

Also to work with several programs at the same time could lead the hardware to its limits.

But there is a trick to reduce the RAM occupation of Windows 10 and to speed up the system.


The Fix

Click to the Windows Start button in the left lower corner of you screen.

Type then “performance” into the search bar. As a search result “Adjust the appearance and performance of Windows” will be in the search result list.

Now this Windows opens:


Now click on “Adjust for best performance” and then “OK”.

Restart your computer!

After the reboot of the computer the Memory/RAM fingerprint of Windows 10 will be much reduced and the computer operates much faster than before.

If the computer still doesn’t operate fast enough a hard disk drive replacement could be considered.


Advice

On old computers often the hard disk causes a performance bottle neck and slows down the whole system. Old HDDs (hard drives) should be replaced with SSDs (Solid-State Drives) and old SSD should be replaced with new SSDs.

This procedure takes more efforts and to reinstall Windows 10. Technical skill is needed as well.


Conclusion

Windows 10 is still current for the next years and if the main task of the user consists in browsing the internet, writing emails and creating documents and spread sheets older hardware can be sufficient. The trick described above can make a significant difference in the speed of the system.

If a low budget solution is required, instead of buying a new computer a hard disk drive change can speed up the computer as well.

Feels free to comment this post!

Ubuntu slow because of Tracker-miner-fs Package


soldering circuit board and a hand

The Problem

Ubuntu 20.04 can be very slow on weaker hardware with low RAM and a weaker CPU. It can be the case that the Ubuntu PC is unusable because CPU usage is very high, although not many applications are opened by the user.

An investigation on an affected PC shows that a specific application called “tracker-miner-fs” caused the high CPU usage and slowed down the PC. Further research showed that “tracker”, version 2, caused the PC to be nearly inoperable.

Linux command line tools like “htop” and “ps -ef” can be used to investigate the details of the running processes and it shows details about the memory and CPU usage.

“Tracker” is an indexing software, which creates and updates a database of the files on the PC’s hard disk drive all the time in the background. On faster and newer hardware it has its advantages, providing metadata for the files on the computer.

But on older hardware it can cause the PC to be inoperable.


The Fix

Several trails of disabling “Tracker” did not work. And: “Tracker” cannot just be uninstalled because the Gnome Desktop, means the whole graphical window system, is dependent on the “Tracker” package. Removing the “Tracker” package would result in a Ubuntu Linux with just a command line interface.

Finally the wooden hammer method worked for me and fixed the trouble we had on the affected system:

sudo chmod -x /usr/libexec/tracker-miner-fs
sudo chmod -x /usr/libexec/tracker-extract
sudo chmod -x /usr/libexec/tracker-store
sudo reboot

The commands above just prevent the “Tracker” binaries to be able to be started. Removing the “execution” permission with the option “-x” in the commands stop the binaries from starting.


Conclusion

The result of the execution of the commands above is a fast running Ubuntu Desktop on older hardware with a little amount of RAM and a weaker CPU. Keep in mind that some cool features of the Gnome Desktop like file meta data info stop working after running the command above.

Have fun with your faster Ubuntu Desktop and comment this blog post!

MySQL – ERROR 1064 (42000): You have an error in your SQL syntax;


Basic Information

MySQL is a database management system for a special kind of SQL databases. SQL databases basically contain a data model and then the data itself. The data model defines the structure for the stored data.

SQL is also the name for the programming language.

The SQL Syntax of the programming language is basically distinguished between the Data Definition Language (DDL) and the Data Manipulation Language (DML). SQL for MySQL is well documented in the internet: https://dev.mysql.com/doc/

MySQL is widespread and a base for many web pages and web systems in the internet. MySQL is open source although some module are closed source. In Linux MySQL can be easily installed and used. There is also an installer for Windows available.


The Problem

Before I upgraded from an older MySQL version to a newer one the following command could be executed successfully:

mysql> GRANT ALL PRIVILEGES ON testdb.* TO testuser@localhost IDENTIFIED BY 'secpasswd';

Executing the command after I upgraded MySQL gave me the following error message:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'secpasswd'' at line 1

The command should basically create a user “testuser” and give this user full access to the database “testdb”. It’s really frustrating because the command above worked for me long time without problems.

But after short trails I found the new way to create a user and to grant access to the database.


The Fix

The complete procedure is listed here:

CREATE database testdb;

The command above creates the databases with the name “testdb”.

CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'secpasswd';

The second command above creates a user (“testuser”) and sets a password.

GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@'localhost';

The last step gives the user “testuser” full access to the database “testdb”. The procedure works for me on MySQL version 8.0.31-0ubuntu0.20.04.2.


Conclusion

Often syntax and commands are changing after system upgrades. Software is often replaced by forks or software which fits better to the users needs. Professionals invest a lot of time to find out how the new versions or the new software works. But on the other side updated and new software comes with new features and bug fixes.

Feel free to comment my post.

Install WordPress and MySQL on Ubuntu

cup of coffee, notebooks, a pen and a table device


WordPress is a software which was initially designed for blogging (weblog) purposes. A blog software can be used to publish content chronologically to the internet. Over the time and with ongoing releases WordPress developed and nowadays it can be used as a basis for ordinary webpages. It can be used similar as Joomla! or Drupal or even Bootstrap (HTML and CSS).

If you want to run your own blog or a small webpage WordPress is first choice.

To customize the base system, a broad range of themes and plugins can be installed. Most of them are free and only advanced use costs money.

WordPress is popular because first successes can be achieved easily a no software development skills are required to set up a nice little web page.

The development of WordPress goes on and the current version is 6 and its sub versions. WordPress is based on PHP and runs on the Apache2 web server and on Linux. This tutorial shows the installation of WordPress on Ubuntu Linux.


1. Install Software

First of all we need to install software on our Ubuntu. Open a terminal and type the following lines to have a web server (Apache2), a database (MySQL) and PHP installed:

sudo apt-get --yes install mysql-server apache2 
sudo apt-get --yes install libapache2-mod-php php-mbstring 
sudo apt-get --yes php-xml php-intl php-mysql
sudo a2enmod php7.4

2. Create the MySQL Database

Now we need to run the MySQL Command Line Interface (CLI). Therefor we need to execute in a terminal:

sudo mysql -u root -p

We are in the MySQL CLI now. Type:

mysql> CREATE DATABASE wordpress;

As the next step, we need to create a user, grant the necessary permissions to the user and at the same time we are setting a password:

mysql> CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'secpasswd';
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';

And then we quit the MySQL CLI:

mysql> FLUSH PRIVILEGES;
mysql> quit

3. Download WordPress to the right Directory

Now we need to download and extract WordPress in a terminal/shell with these commands:

cd /var/www/html
sudo wget https://wordpress.org/latest.zip
sudo unzip latest.zip

To not run into an error during the installation, the ownership for the WordPress directory has to be changed. On my Ubuntu system the “www-data” user and the “www-data” group need to have the ownership of the directory structure. Run the following command:

chown -R  www-data:www-data /var/www/html/wordpress

6. Install and Configure WordPress

Next, open an internet browser and connect to “http://localhost/wordpress”.

Select a language and click on “Let’s go!”. Now the fine tuning has to be done. Provide these settings:

Database: "wordpress" 

Username: "wordpress"

Password: "secpasswd"

Database Host: "localhost"

Click to “Submit” and on the next page “Run the installation”.

Provide now “Site Title”, the WordPress “Username”, a secure WordPress password, your email address and click to “Install WordPress”.


Conclusion

Congratulations! You successfully installed WordPress on your Ubuntu computer! Open a browser and connect to “http://localhost/wordpress/” and login. You can check out now the backend of WordPress and you have a basic site set up for future customization.

Continue with installing themes and plugins and the configuration of menus. It’s just easy to go on from this point.

If you are interested in other CMS, check out my Joomla!, CMSimple or Confluence tutorials!

Feel free to comment this post!

consulting picture

WordPress Cookie Notice by Real Cookie Banner