Category: DevOps
-
SSH-ADD on Windows
If you receive the following error when running the ssh-add command: Could not open a connection to your authentication agent, try this:
cd path-to-Git/bin (for me : cd C:\Program Files\Git\bin) bash exec ssh-agent bash ssh-add REPLACE_WITH_SSHKEY
-
SSH to Siteground on Windows
Step 1: Creating the key
Create your SSH key in the Siteground panel. Give it a password and set a name for it. You can use the tutorial here: https://www.siteground.com/kb/access-site-ssh-connection/
You will need the ssh-add command which comes with the OpenSSH Authentication Agent Properties. To enable the agent, you need to open up the Services app (click on start and type Services for Windows 10+) then scroll through the list and make sure the OpenSSH Authentication Agent Properties is enabled.
After enabling it, you will be able to use ssh-add.
More information here: https://stackoverflow.com/questions/18683092/how-to-run-ssh-add-on-windows
Step 2: Connecting
To connect you will still need to have the OpenSSH Authentication Agent Properties enabled. After that, you can use the following syntax to connect:
ssh user@host -p port number / ssh test@host.com -p 1234
Usually, if everything is correct you are not prompted for a password, but if you are, you will need to provide the password that you added to the key when creating it.
Needless to say, the connection needs to be done through CMD or Windows PowerShell
-
Get last inserted row ID from WordPress database using
$lastid = $wpdb->insert_id;
added after the insert query
Source: https://stackoverflow.com/questions/1576018/how-to-get-last-inserted-row-id-from-wordpress-database
-
Fix XAMPP MySQL server shutdown unexpectedly
IMPORTANT: do NOT delete
ibdata1
file. You could destroy all your databases.Instead, first try using the MySQL backup folder which is included with XAMPP. So do next steps:
- Rename folder
mysql/data
tomysql/data_old
- Make a copy of
mysql/backup
folder and name it asmysql/data
- Copy all your database folders from
mysql/data_old
intomysql/data
(exceptmysql
,performance_schema
, andphpmyadmin
folders) - Copy
mysql/data_old/ibdata1
file intomysql/data
folder - Start MySQL from XAMPP control panel
Source: https://stackoverflow.com/questions/18022809/how-to-solve-error-mysql-shutdown-unexpectedly
- Rename folder
-
Configure LAMP on Ubuntu
A very good tutorial can be found here: https://chabolla.dev/wamp-lamp-stack-install-on-windows/ and another one here: https://www.how2shout.com/how-to/how-to-install-apache-mysql-php-phpmyadmin-on-windows-10-wsl.html – don’t try them both at the same time, rather take them one at a time.
However, if after following it, for some reason, mysql or phpmyadmin does not work, try one of the following fixes
Very useful stuff
1. If, for some reason you get the following error: Phpmyadmin. mysqli_real_connect(): (HY000/2002): Permission denied. Connection for controluser as defined in your configuration failed – try to use the following fix:
In the file /etc/phpmyadmin/config-db.php, change
$dbserver=’localhost’;
to
$dbserver=’127.0.0.1′;Afterwards, restart Apache2
2. To delete Linux apps from the command line, use the following commands:
sudo apt-get remove --purge mysql* sudo apt-get autoremove sudo apt-get autoclean
you can replace mysql* with any other app name such as php* or phpmyadmin* or apache*. You can also use multiple apps like so:
sudo apt-get remove --purge mysql* php* phpmyadmin* apache*
3. Reconfigure phpmyadmin post-install
sudo dpkg-reconfigure phpmyadmin
mysql user is looking for a home directory, which seems to have not been assigned. To do that, you can execute:
sudo systemctl stop mysql.service sudo usermod -d /var/lib/mysql/ mysql sudo systemctl start mysql.service
or
sudo service mysql stop sudo usermod -d /var/lib/mysql/ mysql sudo service mysql start
5. ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’
Try to remove and reinstall all the apps
5. Create Virtual Hosts
Very useful article here: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04-quickstart
I still wasn’t able to add a virtual host outside the /var/www folder, but I should be able to do it in the future.