Categories
Uncategorized

How to change WordPress password if you forget it.

How to change WordPress password if you forget it?

Imagine that you forgot password yo your WordPress site and cannot login.
But still if you have access to cPanel of your hosting, then you can set new password.
To do this, login to cPanel and open PHP My Admin.

After that select database that belongs to your WordPress site.
If you have multiple WordPress sites in your hosting and you don’t know which one belongs to desired site.
In this case you can login to site by FTP and check content of file wp-config.php.
It should have string that defines database name, for example like this:

/** The name of the database for WordPress */
define( ‘DB_NAME’, ‘google_a2wp533’ );

Okey, when you opened desired database, you need to find table wp_users or wpy5_users in my case:

After that find row with corresponding user name and press link edit on this row.
You will see page with columns:

In this page enter new value for password in user_pass column, select MD5 as function and click “Save” link.
Now you can try to login to your WordPress site.

Good luck and don’t forget your password again:)

Categories
Uncategorized

How to bypass windows max path length in 260 characters?

In windows maximal length of path is defined by MAX_PATH, which is y default has value 260.
But from another side many win32 api can operate with path length up to 32,767 characters.
Starting from Win 10, Windows api does not depend on MAX_PATH value.
To enable it user should change registry.
The registry key Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled (Type: REG_DWORD) must exist and be set to 1.
To enable it using Powershell, please run Powershell as Administrator and run following command:
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

Categories
Uncategorized

Extend partition on Ubuntu 20

Assuming that we have VMware VM with Ubuntu 20 on it and we need to extend partition on which it is installed.

Let’s login to this VM by ssh and check disk space on this partition bu running df -h:
root@va:/home/user# df -h
Filesystem Size Used Avail Use% Mounted on
udev 950M 0 950M 0% /dev
tmpfs 199M 812K 198M 1% /run
/dev/sda2 20G 7.9G 11G 43% /
tmpfs 994M 0 994M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 994M 0 994M 0% /sys/fs/cgroup
tmpfs 994M 0 994M 0% /run/shm
/usr/tmpDSK 994M 0 994M 0% /tmp
tmpfs 199M 0 199M 0% /run/user/1001

In this partition we have 20G.

Now let’s run command fdisk -l:

root@va:/home/user# fdisk -l
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F4E29267-1507-4625-9B78-C3536833769A

Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 41940991 41936896 20G Linux filesystem

We have 2 partitions located on this disk.

Now let’s go to vSphere and extend this disk. You don’t need to shut down the VM for this operation.
Just open VM’s hardware settings and enter new size for the disk. In my case i specified 50 GB as new size.


Let’s reboot VM and check if Ubuntu got new disk size by running fdisk -l again:

root@va:/home/user# fdisk -l
GPT PMBR size mismatch (41943039 != 104857599) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F4E29267-1507-4625-9B78-C3536833769A

Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 41940991 41936896 20G Linux filesystem

Now size is 50 GB and it shows warning about size mismatch.

To increase partition size we need to remove information about partition and create new partition with new size and save it.
To do it you will need to run fdisk /dev/sda:

root@va:/home/user# fdisk /dev/sda

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

GPT PMBR size mismatch (41943039 != 104857599) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

After running fdisk you need to run command d and specify partition number (2 in my case).

Now we need to create new partition by running command n, entering default choices and running command w to save the changes:
Command (m for help): n
Partition number (2-128, default 2):
First sector (4096-104857566, default 4096):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (4096-104857566, default 104857566):

Created a new partition 2 of type 'Linux filesystem' and of size 50 GiB.
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: n

Command (m for help): w

The partition table has been altered.
Syncing disks.

Now we need to reboot VM:
root@va:/home/user# reboot

But still Ubuntu will not see new space, we need to run resize2fs command to resize it:
root@va:/home/user# resize2fs /dev/sda2
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 7
The filesystem on /dev/sda2 is now 13106683 (4k) blocks long.

And now let’s check it by running df -h and we will see that partition has new size 50GB:

root@va:/home/user# df -h
Filesystem Size Used Avail Use% Mounted on
udev 950M 0 950M 0% /dev
tmpfs 199M 812K 198M 1% /run
/dev/sda2 50G 7.9G 39G 17% /
tmpfs 994M 0 994M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 994M 0 994M 0% /sys/fs/cgroup
tmpfs 994M 0 994M 0% /run/shm
/usr/tmpDSK 994M 0 994M 0% /tmp
tmpfs 199M 0 199M 0% /run/user/1001

Categories
Uncategorized

How to see table structure in H2 database

Just enter following sql query:

show columns from table_name;

Categories
Uncategorized

How to Change Column Size in Table

Here is how to increase field length in database. Let us say you have a VARCHAR column with length 20, and want to increase its length to 255.
You need to change columnt type in database to increase coolumn size.

Here is how to do it:

ALTER TABLE table_name
MODIFY column_name
varchar(new_length);
In the above command, you need to specify table_name whose column you want to modify, column_name of column whose length you want to change, and new_length, new size number.

Categories
Uncategorized

How to export VMware VM to OVA template

  1. Install VMware PowerCLI powershell module:

Install-Module -Name VMware.PowerCLI

2. Connect to server

Connect-VIServer 10.10.10.10

It will ask for credentials.

In case if you see error “Error: Invalid server certificate”, you will need to check Error: Invalid server certificate article.

3. Export VM

export-vm -vm vm-name -format OVA

It will export OVA and save it to tour current directory.

Also you can specify -destination parameter to local folder where this ova will be saved.

For example:

That’s it.

Categories
Uncategorized

How to fix Connect-VIServer “Error: Invalid server certificate”

If you see following error when trying to connect to host useing Connect-VIServer:

Connect-VIServer : 6/14/2021 3:16:08 PM Connect-VIServer Error: Invalid server certificate. Use Set-PowerCLIConfiguration to set the value for the InvalidCertificateAction option to Prompt
if you’d like to connect once or to add a permanent exception for this server.
Additional Information: Could not establish trust relationship for the SSL/TLS secure channel with authority ‘xx.xx.xx.xx’.
At line:1 char:1

  • Connect-VIServer 10.30.21.8
  • ~~~~~~~
    • CategoryInfo : SecurityError: (:) [Connect-VIServer], ViSecurityNegotiationException
    • FullyQualifiedErrorId : Client20_ConnectivityServiceImpl_Reconnect_CertificateError,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer

Just run following powershell command:

Set-PowerCLIConfiguration InvalidCertificateAction=Prompt

Categories
Uncategorized

How to prevent IP spoofing on Ubuntu.

IP spoofing is the creation of network packets with fake IP
addresses in order to log in from another IP address.

1. To prevent open the file "/etc/host.conf":
sudo vi /etc/host.conf

2. Replace the following lines:
The "order" line is only used by old versions of the C library.
​order hosts,bind
​multi on

With following lines:
The "order" line is only used by old versions of the C library.
​order bind,hosts
​nospoof on

That's it.

Categories
Uncategorized

ZWNBSP meaning.

ZWNBSP is Unicode character ZERO WIDTH NO-BREAK SPACE also known as BOM.

The word joiner (WJ) is a format character in Unicode used to indicate that word separation should not occur at a position, when using scripts that do not use explicit spacing. It is encoded since Unicode version 3.2 (released in 2002) as U+2060 WORD JOINER (HTML ⁠ · ⁠). The word joiner does not produce any space and prohibits a line break at its position.

The word joiner replaces the zero width no-break space (ZWNBSP), a deprecated use of the Unicode character at code point U+FEFF. Character U+FEFF is intended for use as a Byte Order Mark (BOM) at the start of a file. However, if encountered elsewhere, it should, according to Unicode, be treated as a “zero width no-break space”. The deliberate use of U+FEFF for this purpose is deprecated as of Unicode 3.2, with the word joiner strongly preferred.

Categories
Uncategorized

How to fix Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 96 bytes) in

Once i visited my site and found it’s broken and shows following error:

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 96 bytes) in /home/globalre/globalrecruiters.com.ua/www/wp-content/themes/Avada/includes/lib/inc/class-fusion-settings.php on line 170

Let’s open wp-includes/default-constants.php and see default constants:

function wp_initial_constants() {
global $blog_id;

/**#@+
 * Constants for expressing human-readable data sizes in their respective number of bytes.
 *
 * @since 4.4.0
 */
define( 'KB_IN_BYTES', 1024 );
define( 'MB_IN_BYTES', 1024 * KB_IN_BYTES );
define( 'GB_IN_BYTES', 1024 * MB_IN_BYTES );
define( 'TB_IN_BYTES', 1024 * GB_IN_BYTES );

define( 'WP_MEMORY_LIMIT', '128M' );
/**#@-*/

// Start of run timestamp.
if ( ! defined( 'WP_START_TIMESTAMP' ) ) {
    define( 'WP_START_TIMESTAMP', microtime( true ) );

Now let’s change it and set WP_MEMORY_LIMIT to 128M.

function wp_initial_constants() {
global $blog_id;

/**#@+
 * Constants for expressing human-readable data sizes in their respective number of bytes.
 *
 * @since 4.4.0
 */
define( 'KB_IN_BYTES', 1024 );
define( 'MB_IN_BYTES', 1024 * KB_IN_BYTES );
define( 'GB_IN_BYTES', 1024 * MB_IN_BYTES );
define( 'TB_IN_BYTES', 1024 * GB_IN_BYTES );

define( 'WP_MEMORY_LIMIT', '128M' );
/**#@-*/

// Start of run timestamp.
if ( ! defined( 'WP_START_TIMESTAMP' ) ) {
    define( 'WP_START_TIMESTAMP', microtime( true ) );
}