Category: WEb-ART

How to find the WordPress version from command line

How to find the WordPress version from command line

Is there any way to check the WordPress version from the command-line?

Checking version is an important measure for a CMS website owner.

WordPress is one of the commonly using CMS (Content Management System) nowadays. From the WP dash board we can easily check the current version installed. You can check this from “Updates” section under dashboard.

wpversion

It’s very simple and easy to find the WordPress version from command line. Run the following command from the public_html (or the directory where you installed the WP) of your domain:

# grep wp_version wp-includes/version.php

Please see the sample output below:

root@vps [/home/user1/public_html]# grep wp_version wp-includes/version.php
* @global string $wp_version
$wp_version = '3.8';

That’s it.. 🙂

Related

1, How to reset WordPress admin password from cPanel
2, Top 10 WordPress themes for web hosting companies
3, 10+ WordPress Web-hosting themes and templates – Demo and download

How to reset WordPress admin/users password from Linux command line?

We can change the WordPress users (Admin and other users) password in many ways.

  •  From WordPress dashboard.
  •  Via PhpMyAdmin in cPanel. [Explained above]
  •  From MySQL command prompt.

The first option is simple. If you know the current password go ahead and reset it from WordPress dashboard. This can be done from profile section.

We already discussed the second option. Please see the above link.

Here we go with the third option. Reseting WordPress users password from MySQL command prompt. 

The post How to find the WordPress version from command line appeared first on Crybit.com.

How to reset WordPress admin/users password from Linux command line?

How to reset WordPress admin/users password from Linux command line?

WordPress reset password options..

We know how it can be done via PhpMyAdmin option in cPanel. We already discussed this in one of the previous post! Please check this post first, if you have a PhpMyAdmin panel and you’re comfortable with that..

How to reset WordPress admin password from cPanel?

here are many ways to reset the WordPress admin password. We can reset the WordPress admin password from WordPress admin panel as well as cPanel-PHPMyAdmin.

We all know how to reset the wp-admin password from the WordPress Dashboard. It is time that every WordPress blogger knew how to reset the WordPress admin password from PHPMyAdmin. Read more..

It’s simple.

We can change the WordPress users (Admin and other users) password in many ways.

  •  From WordPress dashboard.
  •  Via PhpMyAdmin in cPanel. [Explained above]
  •  From MySQL command prompt.

The first option is simple. If you know the current password go ahead and reset it from WordPress dashboard. This can be done from profile section.

We already discussed the second option. Please see the above link.

Here we go with the third option. Reseting WordPress users password from MySQL command prompt. It’s simple. Please do follow the steps explained below:

1, Log into server as root.

2, Enter to MySQL command prompt.

[root@vps ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 265
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> 
mysql> 

3, Use WordPress database.

You can check the database name from the WordPress configuration file.

mysql> use user_images;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
~

4, Verify user details from “wp_users” table.

We need to select only the following details from “wp_users” table.

mysql> SELECT ID, user_login, user_pass FROM wp_users;
+----+------------+------------------------------------+
| ID | user_login | user_pass                          |
+----+------------+------------------------------------+
|  1 | admin      | $P$BjUKUieEYT1B3TnkQHsv4Y8hfnSK5t. |
+----+------------+------------------------------------+
1 row in set (0.00 sec)

mysql> 

This WordPress has only one user “Admin”. The password displayed here isn’t real, it’s in MD5 encrypted format.

5, Updating user password.

This is the point that we are looking for. As I mentioned, the password displayed is in MD5 format. In latest MySQL versions we can generate the password in MD5 format from the commandline itself. Please see the syntax:

mysql> UPDATE wp_users SET user_pass = MD5(‘WPEXPLORER’) WHERE ID=1 LIMIT 1;

In previous versions we have to enter the password in MD5 format. It’s simple, we can generate it from here >> MD5 <<

Syntax to change the password

mysql> UPDATE wp_users SET user_pass = "61250b88abfe298f2df4821d081a3add"  WHERE ID=1;

Here the user pass in MD5 format.

See the updated password:

mysql> SELECT ID, user_login, user_pass FROM wp_users;
+----+------------+----------------------------------+
| ID | user_login | user_pass                        |
+----+------------+----------------------------------+
|  1 | admin      | 61250b88abfe298f2df4821d081a3add |
+----+------------+----------------------------------+
1 row in set (0.00 sec)

mysql> 

Screenshot from 2015-04-25 19-55-07

That’s it!! Now try to login with the new password.

Related posts

1, How to find the WordPress version from command line.
2, Top 10 WordPress themes for web hosting companies
3, 10+ WordPress Web-hosting themes and templates – Demo and download

The post How to reset WordPress admin/users password from Linux command line? appeared first on Crybit.com.

[Solved] Database Upgrade Required – a detailed view!

[Solved] Database Upgrade Required – a detailed view!

WordPress – Database Upgrade Required – a detailed view!

It’s getting frustrated 🙁 After the WordPress upgrade I’m not able to login.

It’s redirecting me while trying to login. While trying to log into the Dashboard, it’s redirecting to the installation page.

It seems something wrong happened with my last WP upgrade. After a long search found some details about the root cause.

I would like to share those point through this article. Here I’m adding the steps for painless trouble shooting of this issue and the solution.

Error

Database Update Required

WordPress has been updated! Before we send you on your way, we have to update your database to the newest version.

The update process may take a little while, so please be patient.

Update WordPress Database

Yes, of-course there will be an option to upgrade database. I clicked on it and that shows a success message:

Update Complete

Your WordPress database has been successfully updated!

Continue

Oops.. Not helped yet!

databaseupgrade1-thumb

It can occurs as a result of many reasons. Here we goes with some explanations.

It is not a big deal. You can safely do the changes without the afraid of data loss. It’s a table related problem.

In WordPress database, there is table named “WP_Options” which includes some general information related to the blog which appears in the setting tab of admin.

We have to check the following things to troubleshoot this.

1, This might be due to the siteURL mistake in WP_Options table.

Site URL in WP_Options table must be populated to the home page of the website.
You can check this from the PhpMyAdmin.

Log into panel >> Click on PhpMyAdmin >> Select the database from left side >> Click on the table "WP_Options" >> Check the siteURL option.

siteURL

2, Next is important, check the DB version in version.php file. The DB version should match with the WordPress version installed.

This can also do from the PhpMyAdmin “WP_Options” table.

dbversion

Also, you can change this from backend. The “version.php” file is located under:

public_html/wp-includes/version.php

Example:

/**
 * The WordPress version string
 *
 * @global string $wp_version
 */
$wp_version = '4.2.2';

/**
 * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
 *
 * @global int $wp_db_version
 */
$wp_db_version = 31535;

The database and db version table:

You can check the updated details from here >> WordPress version and its db version <<

If none of the above helped, please restore the DB from its previous backup.
That’s it, let me know your suggestions on it.

Also read:

1, How to reset WordPress admin/users password from Linux command line?
2, How to find the WordPress version from command line?
3, How to reset WordPress admin password from cPanel?

The post [Solved] Database Upgrade Required – a detailed view! appeared first on Crybit.com.

Managing comments on your WordPress site via PhpMyAdmin or SQL

Managing comments on your WordPress site via PhpMyAdmin or SQL

Manage WordPress comments via MySQL commands.

This is something interesting and time saving method. Yeah, it’s a bulk, one click option to remove unwanted comments from your WordPress websites. If you are using multiple WordPress websites, this should help you to save many hours.

If your WordPress sites are not properly configured against Spam comments, you may receive 100s of comments per day or week.

You can use any of the Anti Spam plugins available on internet, against this type of Spam comments attack on your website. You can remove those comments from the WordPress dashboard

Access WordPress dashboard → Click on “Comments” from the left side tab → You can sort and select comments from there → Select bulk action.

This image will help you on how to do so:

remove-wordpress-comment

But you can only select a maximum of 20 comments from there. That’s the only problem. If you have to remove 1000s of emails this method will be a painful one. Here we are going with a smart solution for this problem. Yeah you can do this from the PhpMyAdmin tab via cPanel/WHM or from the MySQL interface via command line.

How to remove unwanted comments from from your WordPress site?

The comments are categorized as Pending, Approved, Spam and Trash. Here you can select anyone of this to execute the MySQL query.

Step 1 : Log into cPanel and access PhpMyAdmin.

Step 2 : Select the database correctly.

Step 3 : Click on SQL tab; then execute your query.

remove-wordpress-comment-1

Managing approved comments

You can select all approved comments by executing the following command:

use database_name;
select * from wp_comments WHERE comment_approved='1';

To remove all approved comments from your WordPress’s database, use the following query:

use database_name;
delete * from wp_comments WHERE comment_approved='1';

Select and remove all unapproved comments

Here replace 1 in the above command to 0, that’s it.

You can select all unapproved comments by executing the following command:

use database_name;
select * from wp_comments WHERE comment_approved='0';

To remove all unapproved comments from your WordPress’s database, use the following query:

use database_name;
delete * from wp_comments WHERE comment_approved='0';

Managing Spam and Trash comments

remove-wordpress-comment-2

You can select all Spam comments by executing the following command:

use database_name;
select * from wp_comments WHERE comment_approved='spam';

To remove all Spam comments from your WordPress’s database, use the following query:

use database_name;
delete * from wp_comments WHERE comment_approved='spam';

You can select all Trashed comments by executing the following command:

use database_name;
select * from wp_comments WHERE comment_approved='trash';

To remove all Spam comments from your WordPress’s database, use the following query:

use database_name;
delete * from wp_comments WHERE comment_approved='trash';

That’s it buddy!!
Let me know if you have any questions.

  1. Accessing PhpMyAdmin without cPanel login?
  2. All details about a cPanel user in a single command

The post Managing comments on your WordPress site via PhpMyAdmin or SQL appeared first on Crybit.com.

[Solved] Slowness to access WP dashboard – ModSecurity

It was a WordPress website.

The client had a complaint about the slowness while logging into this WordPress website’s dashboard. The website was configured with CloudFlare DNS. After a quick inspection, I suggest him to disable the CloudFlare CDN for his main domain.

This domain was using CloudFlare SSL too. The website was loading without any slowness, only problem with Dashboard.

I checked the Web server’s (Apache) error log and noticed the following errors:

[Wed Aug 09 15:33:48 2017] [error] [client 2.1.2.2] ModSecurity: Output filter: Response body too large (over limit of 524288, total not specified). [hostname "domain.com"] [uri "/wp-admin/index.php"] [unique_id "WYtjmkSr2WIAAcbwMwAAAAAJ"]

[Wed Aug 09 15:33:59 2017] [error] [client 2.1.2.2] ModSecurity: Output filter: Response body too large (over limit of 524288, total not specified). [hostname "domain.com"] [uri "/wp-admin/index.php"] [unique_id "WYtjnkSr2WIAAcgXULgAAAAL"]

Yeah, the ModSecurity was the offender, LOL!! Actually, the WAF (Web Application Firewall) ModSecurity was disabled on that domain.

How to disable Mod security rule for a domain in cPanel server?

Mod security is an Apache module that helps to protect your website from various attacks. It is used to block commonly known exploits using regular expressions and rule sets. It blocks injection attacks which secure your server. We use mod_security1 for Apache1.x and mod_security2 for Apache2.x. In case of mod_security1, we can disable mod_security for a domain using .htaccess file. Read more…

Here the error is:

ModSecurity: Output filter: Response body too large (over limit of 524288, total not specified)

This is due to the memory limit to store maximum request body size. To fix this error, we need to increase the values of following parameters:

SecResponseBodyLimit & SecRequestBodyInMemoryLimit

SecResponseBodyLimit

Description: Configures the maximum response body size that will be accepted for buffering.
Syntax: SecResponseBodyLimit LIMIT_IN_BYTES
Example Usage: SecResponseBodyLimit 524228
Scope: Any
Version: 2.0.0
Supported on libModSecurity: Yes
Default: 524288 (512 KB)
Anything over this limit will be rejected with status code 500 (Internal Server Error). This setting will not affect the responses with MIME types that are not selected for buffering. There is a hard limit of 1 GB.

SecRequestBodyInMemoryLimit

Description: Configures the maximum request body size that ModSecurity will store in memory.
Syntax: SecRequestBodyInMemoryLimit LIMIT_IN_BYTES
Example Usage: SecRequestBodyInMemoryLimit 131072
Scope: Any
Version: 2.0.0
Supported on libModSecurity: Yes
Default: 131072 (128 KB)
When a multipart/form-data request is being processed, once the in-memory limit is reached, the request body will start to be streamed into a temporary file on disk.

First, locate the ModSecurity configuration file. For a cPanel server, it’s located under /usr/local/apache/conf.

root@vps.crybit.com[/usr/local/apache/conf]# ll modsec2.conf
-rw------- 1 root root 882 Aug  9 15:39 modsec2.conf

Open the configuration file with your favorite text editor and add the following entries:

SecResponseBodyLimit 546870912
SecRequestBodyInMemoryLimit 546870912

If the entries are already there, try to increase its value.

Then “restart” web server.

/etc/init.d/httpd restart

Or

service httpd restart

Cool!!
Try to load the dashboard again. It should load faster as expected!!
Let me know your suggestions as comments.

The post [Solved] Slowness to access WP dashboard – ModSecurity appeared first on Crybit.com.

How to reset WordPress admin password from cPanel?

How to reset WordPress admin password from cPanel?

How to change WordPress users password – PhpMyAdmin?

There are many ways to reset the WordPress admin password. We can reset the WordPress admin password from WordPress admin panel as well as cPanel-PHPMyAdmin. We all know how to reset the wp-admin password from the WordPress Dashboard. It is time that every WordPress blogger knew how to reset the WordPress admin password from PHPMyAdmin.

Read : How to reset WordPress admin/users password from Linux command line?

We can change the WordPress users (Admin and other users) password in many ways.

1, From WordPress dashboard.
2, Via PhpMyAdmin in cPanel.
3, From MySQL command prompt.

The first option is simple. If you know the current password go ahead and reset it from WordPress dashboard. This can be done from profile section.

We already discussed the second option. Please see the above link.

Here we go with the third option. Reseting WordPress users password from MySQL command prompt. It’s simple. Read more….

WordPress is one of the most popular and widely used content management system. Because of its popularity and ease of use it’s always being exposed to several security vulnerabilities or hacks.

In case if a WordPress website is hacked, we may not be able to enter the wp-admin panel. Also, when we are upgrading a new theme or plugin for our WordPress website, then our website and admin panel may gets Internal error or white pages, it there any incompatibility issues.

In those cases, as a Sys Admin it’s very important to know, how we can reset the wp-admin password from PHPMyAdmin.

Here I am explaining how you can change the wp-admin password from PHPMyAdmin.

1. Obviously you should log into cPanel with your username and password. Then, select PHPMyAdmin from “Databases” tab.

cPanel > Databases > PHPMyAdmin

pic1

2. Identify the database

We can identify the database that you are using for your WordPress website, from wp-config.php file. In that file, you can see the following entries which defines your Database name, Database user, Database password and Database host.

A sample wp-config file which lists the database details is shown below:

/** The name of the database for WordPress */
define('DB_NAME', 'crybit_wordp1');

/** MySQL database username */
define('DB_USER', 'crybit_wordp1');

/** MySQL database password */
define('DB_PASSWORD', 'password_of_the_database');

/** MySQL hostname */
define('DB_HOST', 'localhost');

Database name format in a cPanel server is “cpanelusername_name of db”. The database name in this example is “crybit_wordp1“.

Now, in the PHPMyAdmin you can see your databases listed in left side. Select and click on the database name that you see in the wp-config.php file. Then, you will see a list of tables that starts with “wp_” for most of the part.

***If you have changed the prefix in the installation time, then you need to search for the specific prefix. For example: “wpmy_

3. Identify the table

Then, we need to search for the table wp_users and click on the database table. It will lists the WordPress users. Click on the Edit icon of the user admin if you need to change the password for the admin user.

pic2

Now, you will see a window which looks like this:

pic3

There, you need to edit the user_pass field to change the password. WordPress stores password in MD5 encrypted form. You are not allowed to store a plain text password. For that you need to select MD5 from the drop-down next in the function field.

In the value field, enter your password in plain text format.

pic4

This means, you are converting your plain text password to MD5 encrypted format. Then, click Go to save the changes.

Similarly we can change all WordPress users passwords!

That’s it!!!

Related

1, How to find the WordPress version from command line
2, Top 10 WordPress themes for web hosting companies
3, 10+ WordPress Web-hosting themes and templates – Demo and download

The post How to reset WordPress admin password from cPanel? appeared first on Crybit.com.

Password protect WordPress login – wp-login.php

Password protect WordPress login – wp-login.php

What is password protection?

It’s a smart feature to protect directories against accessing it from unauthorised users. In a cPanel server, we can simply create password protected directories via the control panel (Home >> Security >> Password Protect Directories). If we enable this feature, the system will prompt all users accessing that particular directory with a user name and password window. This provide a second layer of protection to our account on internet. Here I explain, how we can protect the WordPress login page from Brute Force Attack!

Why this topic?

Simply to save your accounts resources 😛 Chance of login attacks are high on WordPress websites as it has a known login page wp-login.php under the installation folder. A DoS to this page can slowdown your website and consume resources. If your WordPress domain is hosted in a CloudLinux platform, you will definitely face the “508 Resource Limit Is Reached” error on your web-page. Here we are going to protect the login page against Brute Force Attack. The steps are simple:

Creating “.htpasswd” file

Yeah, to do password protection first you need to create a .htpasswd file to store the secret authentication details. There are different options available to create this. In a cPanel server, we can create it from the control panel itself. Otherwise you can create this from this online tool >> HTPASSWD GENERATOR << The generated password must be in encrypted form. Then upload the file to your home directory, a best location should be in “/home/user/.htpasswds/public_html/test/wp-admin/“.

File name :: /home/user/.htpasswds/public_html/test/wp-admin/passwd

Then place the code in the WordPress installation directory

passwodpro1

Append the code pasted below into the .htaccess file under WP installation directory.


# copy this code to .htaccess, CryBit.com
# To prevent loops

ErrorDocument 401 default

# Protect wp-login

AuthUserFile /home/user/.htpasswds/public_html/test/wp-admin/passwd
AuthName "Private access"
AuthType Basic
require valid-user


NB : “ErrorDocument 401 default” this line will help you to avoid redirection error.

The above steps will re-prompt the login page:

passwodpro2

That’s it!

Also read;

How to reset WordPress admin/users password from Linux command line?
Database Upgrade Required – a detailed view!

The post Password protect WordPress login – wp-login.php appeared first on Crybit.com.