Click here for "Safe Air Conditioner Repair and Proper Freon Recovery".

Ubuntu22.04 Server : MySQL 8 , WordPress

1. MySQL 8 Install

1. 1Install

# apt -y install mysql-server

1.2. MySQL Server Security Settings

Run the tool mysql_secure_installation to configure security-related settings for the MySQL server.
Once executed, several security settings are initiated in the form of questions.
First, you will be asked if you want to use a plugin for password validation as follows. Password validation is a way to check the strength of a user's password for MySQL and restrict it to only accepting passwords that are secure enough. For example, it must be at least as many characters long as the user's password and must contain at least one symbol and one number. You can set this requirement by asking the following questions
Type y and press Enter if you like

# systemctl restart mysql.service
# mysql_secure_installation

"Failed! Error: SET PASSWORD has no significance for user ‘root’@’localhost’ as the authentication method used doesn’t store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters."

If you get the above error, change the authentication parameters by executing this ALTER query as follows

# mysql
>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'mynewpassword';
# mysql_secure_installation

Installation Status

Securing the MySQL server deployment.

Enter password for user root:mynewpassword  # Not displayed
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password:        ←Any password

Re-enter new password:   ←Retype password

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Enter password for user root:y

... skipping.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...

- Removing privileges on test database...

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

All done!

Finally, the security settings are complete when the message "All done!
From then on, when accessing MySQL, you must use the
# mysql -u root -p
Enter password: (Enter the password set above)

2.WordPress Install

2.1 Database Creation

Create a database for Word Press (for example, in this case, the database name is "wp_db", the user name is "wp_user", and the password is "?Y123456y")
If you receive a message "Your password does not satisfy the current policy requirements" when creating an account, please make sure your password is at least 8 characters long and includes upper and lower case letters, numbers, symbols, etc.

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.29-0ubuntu0.22.04.2 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE DATABASE wp_db DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;Query OK, 1 row affected, 2 warnings (0.00 sec)
mysql> show databases;+--------------------+
| Database |
| information_schema |
| mysql |
| performance_schema |
| sys |
| wp_db |
5 rows in set (0.00 sec)mysql> CREATE USER 'wp_user'@'%' IDENTIFIED WITH mysql_native_password BY '?Y123456y';
Query OK, 0 rows affected (0.00 sec)mysql> GRANT ALL ON wp_db.* TO 'wp_user'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> exit;

2.2 WordPress Download and Install

①Download and Deployment

# cd /var/www/html/<own domain name>
# wget
# tar xvf latest-ja.tar.gz
②Edit WordPress configuration file
# cd wordpress/
# cp wp-config-sample.php wp-config.php
# vi wp-config.php

Edit contents of wp-config.php

// ** MySQL settings – You can get this info from your web host * //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wp_db‘);  ←The name of the database created in “2.1 Database creation”./** MySQL database username */
define(‘DB_USER’, ‘wp_user‘); ←User name created in “2.1 Database creation”./** MySQL database password */
define(‘DB_PASSWORD’, ‘?Y123456y‘); ←Password for the user created in “2.1 Database creation”./**Also, add the following to the last line */
/**If you do not do this, you will be asked for FTP connection information when you add the plugin.*/
define(‘FS_METHOD’, ‘direct’);

③Moving Files

# cd /var/www/html/<own domain name>
# mv wordpress/* .
After confirming that the files have been moved, delete the wordpress directory and downloaded latest-ja.tar.gz
# ls -l
# rm -R -f wordpress
# rm latest-ja.tar.gz
④Make apache the owner of the wordpress directory
# chown -R www-data:www-data /var/www/html/<own domain name>

⑤Access from a browser
Access http://<own domain name>/wp-admin.
If successful, the following WordPress installation information input screen will be output.

Your server’s PHP does not seem to be able to use the MySQL extension required by WordPress.” If you get the message

If you have php and mysql installed on your Ubuntu server, but when you install WordPress you get the message “Your server’s PHP does not seem to be able to use the MySQL extension required by WordPress.” Please check the following.
Make sure you have the library installed、
Install the php library if you haven’t already done so.

# apt -y install php8.1-gd php8.1-mbstring

Installing the MYSQL module
WordPress requires the MYSQL module in PHP.
Install the PHP MYSQL module if you haven’t already done so.

# apt -y install php8.1 php8.1-mysql libapache2-mod-php8.1 php8.1-mysql

After the installation is complete, restart Apache.

# systemctl restart apache2

On the input screen below

  • Site Title :  Any name
  • Username :    Any name
  • Password : Any Password
  • Your Email : Admin E-mail Address

Click on "Install WordPress". Remember to enter your "username" and "password" as they are required to access the WordPress administration screen.