Posts

Showing posts with the label sock

Create a sock proxy to a private network

Last week, I wrote a bash script that can be used to create a sock proxy that connects my computer and a private network via a bastion server (the bastion server is a server that sitting inside a private network that I can ssh into using a pem key). Usage: ./gen_sockproxy.sh /path/to/sshkey.pem <bastion_username> <bastion_address> It will output the sock proxy address. For example:  socks5://localhost:13000

Django DB migration when you're using a custom MySQL installation dir

For some reason, you installed MySQL in a different path than the default /etc/mysql/. Then if you run the Django's migrate command, it will fail because It cannot communicate with the MySQL process: django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)") If that's the case, you can use the following option in your Django's configuration to indicate the socket directory of MySQL: DATABASES = {     'default': {         'ENGINE': 'django.db.backends.mysql',         'OPTIONS': {             'read_default_file': '/path/to/my.cnf',         },     } } That's it. Profit!!!