Tag: MariaDB

  • WordPress: How to manually create a user in the database

    Manually creating a WordPress user in the database involves adding a new entry to the wp_users table and assigning the necessary user capabilities. Here are the steps to do this:

    Please exercise caution when making direct changes to your WordPress database, as incorrect changes can break your site. Make sure to back up your database before proceeding.

    1. Access Your Database:
      Log in to your server or hosting provider’s control panel and access the phpMyAdmin or a similar tool to manage your WordPress database.
    2. Find the wp_users Table:
      In phpMyAdmin, look for your WordPress database on the left-hand side and click to select it. Then, find and click on the wp_users table.
    3. Insert a New User:
      Click the “Insert” or “Add” tab (the exact label may vary depending on your phpMyAdmin version). This will open a form for adding a new row to the wp_users table.
    4. Fill in User Information:
      Fill in the following fields for the new user:
    • user_login: Enter the desired username for the new user.
    • user_pass: Generate a secure password hash. You can use online tools to create password hashes or use WordPress’s built-in wp_hash_password function. Make sure to select the MD5 option when entering the password hash.
    • user_nicename: This can be the same as the user_login.
    • user_email: Enter the email address for the new user.
    • user_registered: Set the registration date in the format “YYYY-MM-DD HH:MM:SS”.
    • display_name: The display name for the user.
    1. Insert the User:
      Click the “Go” or “Insert” button to insert the new user into the wp_users table.
    2. Assign Capabilities:
      To assign capabilities to the user, you’ll need to find the user’s ID in the wp_users table (it’s typically an auto-incremented number) and then add an entry in the wp_usermeta table.
    • Go to the wp_usermeta table.
    • Insert a new row with the following values:
      • user_id: The ID of the new user from the wp_users table.
      • meta_key: Enter wp_capabilities.
      • meta_value: Insert a serialized array with the user’s capabilities. For example, to make the user an administrator, you can use a:1:{s:13:"administrator";b:1;}.
    1. Login to WordPress:
      You should now be able to log in to your WordPress site using the credentials you provided.

    Please be extremely careful when making changes directly to the database, and ensure that you have a backup in case anything goes wrong. It’s recommended to use the WordPress admin interface to create and manage users whenever possible to avoid potential issues.

    WordPress: How to manually create a user in the database
  • LAMP Stack Setup

    Setup for Ubuntu 20.04 LTS or 22.04 LTS. Lifted from this resource on AWS.

    Linux

    WSL, Ubuntu Multipass, or equivalant.

    Apache

    Version: distribution

    sudo apt update -y
    sudo apt install apache2 -y

    PHP FPM

    Version: 8.2

    Run the following commands to install PHP:

    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update -y
    sudo apt install php8.2 php8.2-{fpm,mysql,curl,gd,mbstring,mysql,xml,mcrypt,zip,ldap} libapache2-mod-php8.2 -y

    Install PHP-FPM

    sudo a2enmod proxy_fcgi setenvif
    sudo a2enconf php8.2-fpm
    sudo a2dismod php8.2
    sudo systemctl enable php8.2-fpm
    sudo service apache2 restart;sudo service php8.2-fpm restart

    MariaDB

    Version: 11.1.2

    Run the following command to add the MariaDB yum repository (For all Linux distributions):

    curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-11.1.2"

    Install MariaDB Package

    sudo apt install mariadb-server -y

    MariaDB Secure Installation

    sudo mysql_secure_installation

    When prompted, set a password for the root account:

    • Enter the current root password. By default, the root account doesn’t have a password set.
    • Press Enter.
    • Press N to switch to unix_socket authentication.
    • Press Y to set a password, and then enter a secure password twice. Make sure to store this password in a safe place.
    • Press Y to remove the anonymous user accounts.
    • Press Y to disable the remote root login.
    • Press Y to remove the test database.
    • Press Y to reload the privilege tables and save your changes.

    Permissions

    The following command will add the ubuntu user to the www-data group:

    sudo usermod -a -G www-data ubuntu

    The following commands will set the correct permissions for the /var/www directory:

    sudo chown -R ubuntu:www-data /var/www
    sudo chmod 2775 /var/www
    find /var/www -type d -exec sudo chmod 2775 {} \;
    find /var/www -type f -exec sudo chmod 0664 {} \;

    Your site is ready!

    Visit your website by entering your instance’s public IP address in your browser. You should see the default Apache page.

    LAMP Stack Setup