The best programming blog.

Covering a wide array of programming topics.

How to add robots txt file in WordPress site

Go to Plugins from admin dashboard. Search for Yoast SEO. Install and Activate that plugin. Go to SEO > Tools tab and click File editor option. Click Create robots.txt file button. Click Save changes to robots.txt file after adding your changes to that file. Accessing /robots.txt file will give you the robots.txt file content in…More

How to connect to AWS EC2 instance from local MAC machine

Open an SSH client, MAC’s terminal for an instance. Locate your private key file. The key which was created when the EC2 instance was created. Example: Your-Server-Key-Pair.pem. Put that key at the following location at /Users/<YourMac’sUserName>/SSHKeys on your MAC. Run this command, to ensure your key is not publicly viewable. chmod 400 Your-Server-Key-Pair.pem Connect to…More

How to route a subdomain to an Amazon EC2 instance IP

Go to AWS console dashboard. Search for Route 53 in the search box. Go to Hosted zones and click the zone you want to add the route. Click Create record button to add a record. On the create record form add the following details: Record name: <yourdomain> Record type: A- Routes traffic to an IPV4…More

MySQL Can’t specify target table for update in FROM clause

While running the following update query: UPDATE wp_posts SET post_content = REPLACE(post_content, ‘http://localhost:9000/wp-content/’, ‘http://localhost:9200/wp-content/’) WHERE ID IN ( SELECT ID FROM wp_posts WHERE `post_content` LIKE ‘%http://localhost:9000/wp-content/%’ ); I was getting the folowing error: Error Code: 1093. You can’t specify target table .. for update in FROM clause The solution was to wrap the inner query…More

How to take backup of MySQL database

We will make use of the mysqldump utility to take the backup of a MySQL database. Run the following command to take the backup of a MySQL database: mysqldump -u root -p <database_name> > /<location_where_you_want_to_take_the backup>/<database_name>.sql Example: mysqldump -u root -p my_wordpress_site > /Users/MySQLDumps/my_wordpress_site_dump.sql In the above example, my_wordpress_site is the database name for which…More

zsh: command not found: mysql

When you try to run the mysql command in the terminal but the MySQL client is not correctly installed or configured on your system, you frequently get the error message “zsh: command not found: mysql.” You must set up the MySQL client on your computer in order to address this problem. The following command can…More

Find the MySQL installation directory location in MAC

Run the following command in terminal ps aux|grep mysql The output will come like this: _mysql 4945 0.0 0.0 408186784 656 ?? S Wed06PM 0:03.59 /usr/sbin/distnoted agent _mysql 359 0.0 0.3 36149796 47436 ?? Ss 13Apr22 6:40.99 /usr/local/mysql/bin/mysqld –user=_mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data In the above results get the value of –basedir property. That value represents the…More

zsh: command not found: mysqldump

Open the .zshrc file by running the following command: nano ~/.zshrc Do the following steps in that file: Paste the export PATH=”/usr/local/mysql/bin:$PATH” line in that end of that file. Hit CTRL + O Hit CTRL + Enter Key Hit CTRL + X Above, /usr/local/mysql is base directory location of your mysql installation. You can find…More

How to install WordPress on Mac

The installation will be done in three main steps: Install MySQL. Install PHP. Install WordPress site. Install MySQL You can use the following resource to install MySQL on MAC: After installing it, run create database my_wordpress_site; command to create a database locally to your mysql instance: Connect to mysql instance first: mysql -u root -p…More

php: command not found on MAC

On MAC if you are running the php command in the terminal and getting the php: command not found then you can try the following steps to solve that: zshrc Open the .zshrc file by running the following command: nano ~/.zshrc Do the following steps in that file: Paste the export PATH=”/opt/homebrew/opt/php@7.4/bin:$PATH” line in that end…More