Archive for February, 2016

MySQL – ERROR 1045 (28000): Access denied for user

February 16, 2016

Everybody knows Mysql. Normally it “just works”. But a few days ago I tried to connect to a mysql server with the mysql command line client and got this error.

ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

Funny thing: If you want to use the mysql command client to connect with the mysql server, you can do something like this

mysql -u root -pPassword

Where does it try to connect itself? To localhost and the well known port 3306? Wrong. It tries to access the mysql socket file. Which in my case, was not existing (because I had mysql in a docker container). I just wanted to connect via IP address and port.

Next try: Access the server via host parameter

mysql -u root-pPassword -h127.0.0.1

But: Same error! If the mysql client sees the ip address 127.0.0.1, it tries the socket file again! You have to explicitly tell the mysql client to use TCP to connect.

mysql -u root-pPassword -h127.0.0.1 –protocol=tcp

(Thanks to stackexchange for this information!)

The Last Programming Language

February 13, 2016

A talk about the history of Software programmers by Robert Martin. Nice except the end. There he does not see the inherent conflict of interest between someone wanting to see programming as a craft and the interest of businesses to make money.

A reminder how to use Journalctl

February 12, 2016

On digitalocean.com you can find a nice and to the point written introduction to the systemd logging utility journalctl.

Some of the most compelling advantages of systemd are those involved with process and system logging. When using other tools, logs are usually dispersed throughout the system, handled by different daemons and processes, and can be fairly difficult to interpret when they span multiple applications.Systemd attempts to address these issues by providing a centralized management solution for logging all kernel and userland processes. The system that collects and manages these logs is known as the journal.

The journal is implemented with the journald daemon, which handles all of the messages produced by the kernel, initrd, services, etc. In this guide, we will discuss how to use the journalctl utility, which can be used to access and manipulate the data held within the journal.

If you are using a modern linux distribution and you need to work with logs – then this may be a good text for you.

How to add a new systemd unit on debian 8

February 7, 2016

I’m running the tiny tiny rrss webapp on my server. Last time I installed it, I used screen to daemonize the update_daemon2.php script to update the rss feeds. This time I wanted to do it right with a new systemd daemon (like suggested on the tiny tiny rss website). Sadly enough I didn’t find any debian related information how to add a new systemd unit. At last I found a community forum entry which describes this.

Beware: Maybe this is not the right way to do it ™. If you have a better idea how to manage this, please tell me!

  • Create a systemd unit file (e.g. ttrss.service) in the directory /lib/systemd/system
  • The file contains something likes this:

[Unit]
Description=ttrss_backend
After=network.target mysql.service postgresql.service

[Service]
User=www-data
ExecStart=/var/www/stefan/ttrss/public_html/update_daemon2.php

[Install]
WantedBy=multi-user.target

  • Create a symlink like that ln -s /lib/systemd/system/ttrss.service /etc/systemd/system/multi-user.target.wants/ttrss.service
  • Reload the systemd daemon systemctl –system daemon-reload
  • Start the systemd unit systemctl start ttrss.service

With the command systemctl status ttrss.service  you can monitor the activities of the service. It outputs something like this

ttrss.service – ttrss_backend
Loaded: loaded (/lib/systemd/system/ttrss.service; enabled)
Active: active (running) since Sun 2016-02-07 13:39:18 CET; 19min ago
Main PID: 948 (php)
CGroup: /system.slice/ttrss.service
└─948 php /var/www/XXXX/update_daemon2.php

Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:44/1371] cache/export: removed 0 files.
Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:44/1371] cache/upload: removed 0 files.
Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:44/1371] Removed 0 old lock files.
Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:44/1371] Removing old error log entries…
Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:45/1371] Feedbrowser updated, 78 feeds processed.
Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:45/1371] Purged 3 orphaned posts.
Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:45/1371] Removed 0 (feeds) 0 (cats) orphaned counter cache entries.
Feb 07 13:57:46 v22016013319431489 update_daemon2.php[948]: [12:57:46/948] [reap_children] child 1368 reaped.
Feb 07 13:57:46 v22016013319431489 update_daemon2.php[948]: [12:57:46/948] [SIGCHLD] jobs left: 0
Feb 07 13:58:27 v22016013319431489 update_daemon2.php[948]: [12:58:27/948] [MASTER] active jobs: 0, next spawn at 60 sec.

But again: If you know a better way how to do this with debian, please tell me!