MySQL Error 2002

server1@server1:~$ mysql -uroot -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Installed MySQL server

$ sudo apt-get install mysql-server

If in windows:
getting this error maybe because mysqld is not running. In cmd run,
$ mysqld

to check if its running you can see if the you’re listening to the port 3306
$ netstat -a -n

to check if its running you can telnet it
$ telnet localhost 3306

A useful tool
$ mysqladmin

XAMPP troubleshoot

XAMPP on linux ubuntu stopped working I belive it was because I
ran the python barebones server script. While XAMPP was running I
would go to http://localhost and the page wouldn’t load. So I tried
to restart xamp
$ sudo opt/lampp/lampp restart

I received this error message

(20014)Internal error: Error retrieving pid file logs/
Remove it before continuing if it is corrupted.

so I deleted the logs/ file, restarted LAMPP and it started to work again

troubleshoot, linux ubunut

Python Barebones Web Server

page 56 from Programming python O'Reilly 4th edition
Implement an HTTP web server in Python that knows how to run server-side
CGI scripts coded in Python; serves files and scripts from current working
dir; Python scripts must be stored in webdir\cgi-bin or webdir\htbin;
import os, sys
from http.server import HTTPServer, CGIHTTPRequestHandler

webdir = '.' # where your html files and cgi-bin script directory live
port = 80 # default http://localhost/, else use http://localhost:xxxx/

os.chdir(webdir) # run in HTML root dir
srvraddr = ("", port) # my hostname, portnumber
srvrobj = HTTPServer(srvraddr, CGIHTTPRequestHandler)
srvrobj.serve_forever()# run as perpetual daemon

mini small