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

openSUSE ; Install Mysql & WordPress

1. Install Mysql8

First, make sure the server is up to date.

Update the server package
# zypper ref
# zypper up -y 

1.1 Mysql8 install

①Importing the MySQL 8.0 repository
Download the RPM repository
# wget https://dev.mysql.com/get/mysql80-community-release-sl15-4.noarch.rpm
Import the downloaded repository
# rpm -ivh mysql80-community-release-sl15-4.noarch.rpm
Importing GPG keys
# rpm –import /etc/RPM-GPG-KEY-mysql
Update the repository
# zypper refresh
②Check the information on the listed packages.
Make sure you have the required version of mysql.

# zypper info mysql-community-server
Loading repository data…
Reading installed packages…

Information for package mysql-community-server:
———————————————–
Repository : MySQL 8.0 Community Server
Name : mysql-community-server
Version : 8.0.27-1.sl15
Arch : x86_64
Vendor : Oracle and/or its affiliates
Installed Size : 2.83 GiB
Installed : Yes
Status : up-to-date
Source package : mysql-community-8.0.27-1.sl15.src
Summary : A very fast and reliable SQL database server
Description :
The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
and robust SQL (Structured Query Language) database server. MySQL Server
is intended for mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Oracle and/or its affiliates
・・・・Abbreviation・・・
This package includes the MySQL server binary as well as related utilities
to run and administer a MySQL server.

③Install mysql server.
# zypper install mysql-community-server
④Make sure it is installed.

# rpm -qi mysql-community-server
Name : mysql-community-server
Version : 8.0.27
Release : 1.sl15
Architecture: x86_64
Install Date: Fri Jan 7 22:45:00 2022
Group : Applications/Databases
Size : 3039099718
License : Copyright (c) 2000, 2021, Oracle and/or its affiliates. Under GPLv2 license as shown in the Description field.
Signature : DSA/SHA256, Wed Sep 29 16:36:37 2021, Key ID 8c718d3b5072e1f5
Source RPM : mysql-community-8.0.27-1.sl15.src.rpm
Build Date : Wed Sep 29 00:13:00 2021
Build Host : pb2-opensuse15-01.appad3iad.mysql2iad.oraclevcn.com
Relocations : (not relocatable)
Packager : MySQL Release Engineering <mysql-build@oss.oracle.com>
Vendor : Oracle and/or its affiliates
URL : http://www.mysql.com/
Summary : A very fast and reliable SQL database server
Description :
・・・・・Abbreviation・・・・
This package includes the MySQL server binary as well as related utilities
to run and administer a MySQL server.
Distribution: (none)

⑤Start and enable the mysql service

# systemctl start mysql
Make the service start on reboot.
# systemctl enable mysql
Check the status of the service and make sure it is actually running.
# systemctl status mysql
● mysql.service – MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; vendor pre>
Active: active (running) since Sat 2022-01-08 08:21:14 JST; 1h 11min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 1412 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status>
Main PID: 1484 (mysqld)
Status: “Server is operational”
Tasks: 37 (limit: 2308)
CGroup: /system.slice/mysql.service
mq1484 /usr/sbin/mysqld
Jan 08 08:21:07 Lepard systemd[1]: Starting MySQL Server…
Jan 08 08:21:14 Lepard systemd[1]: Started MySQL Server.
Active: active (running) Indicates that the service is running
⑥View MySQL 8 service logs
Use the journalctl command
# journalctl -u mysql -xe
# tail -f /var/log/mysql/mysqld.log
⑦Security of mysql installation
Change the password for the root user of the Mysql server.
Check the ‘temporary password’ after installation and make a note of it.
# grep ‘temporary password’ /var/log/mysql/mysqld.log
2022-01-07T13:59:50.849820Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 8LvNl4sjV9=1
Log in with a temporary password (8LvNl4sjV9=1), change the root password as soon as possible, and set a custom password for the superuser account.

# mysql -u root -p
Enter password: ‘temporary password’
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.27
Copyright (c) 2000, 2021, 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
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘Any new root password’;
Query OK, 0 rows affected (0.02 sec)
exit
Bye

⑧Check mysql version

# mysql -V
mysql Ver 8.0.27 for Linux on x86_64 (MySQL Community Server – GPL)

Log in as the root user with the newly specified root password.
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.27

Copyright (c) 2000, 2021, 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
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> select version(); ← Check mysql version
+———–+
| version() |
+———–+
| 8.0.27 |
+———–+
1 row in set (0.00 sec)

mysql> exit;
Bye

1.2 Example of creating  Mysql8 database and user

Try to create a user, password, and database for wordpress to install in the following
database :  wp_db
user : wp_user
password : ?WHxx333Yo

# mysql -u root -p
① Create a database
mysql> create database wp_db;
Query OK, 0 rows affected (0.14 sec)

➁Create user
mysql> create user ‘wp_user’@’localhost’ identified with mysql_native_password by ‘?WHxx333Yo’;
Query OK, 0 rows affected (0.14 sec)

➂Setting user rights
mysql> grant all on wp_db.* to wp_user@’localhost’ with grant option;
Query OK, 0 rows affected (0.14 sec)

④Settings reflect
mysql> flush privileges;
Query OK, 0 rows affected (0.22 sec)

mysql>exit
Bye

2. Install WordPress

2.1 Install required libraries

# zypper install php-gd php-pdo php-mysql php-mbstring php-simplexml php-curl apache2-mod_php7

2.2 Download and install WordPress

# cd /srv/www/htdocs/[web directory]
# wget http://ja.wordpress.org/latest-ja.tar.gz
# tar zxvf latest-ja.tar.gz

2.3 Edit the configuration file

# cd  /srv/www/htdocs/[web directory]/wordpress/
# cp wp-config-sample.php wp-config.php
# vi wp-config.php

define(‘DB_NAME’, ‘wp_db‘);

define(‘DB_USER’, ‘wp_user‘);

define(‘DB_PASSWORD’, ‘?WHxx333Yo‘);

#Add the following to the last line.
#When you add a plugin, you will be asked for FTP connection information.
define(‘FS_METHOD’, ‘direct’);

Move the extracted contents under /srv/www/htdocs/[web directory]

# cd /srv/www/htdocs/[web directory]
# mv wordpress/* .
After confirming that the files have been moved, delete the wordpress directory and the downloaded latest-ja.tar.gz.
# cd /srv/www/htdocs/[web directory]
# rm -Rf wordpress
# rm latest-ja.tar.gz
Make apache the owner of the wordpress directory.
# chown -R wwwrun:wwwrun /srv/www/htdocs/[web directory]
# chmod 775 -R /srv/www/htdocs/[web directory]
# systemctl restart apache2

2.4 startup confirmation

Connect to http://<server name>/wp-admin/install.php with a browser, enter your user name, password and other necessary information, and start the installation.
Normally, this will bring up the initial installation screen, including the “User Name” and “Password” to access the WordPress administration screen as shown below.
Site Title : Any title
Username : Any Name
Password : Any password
Your Email : Administrator’s email address
Click “Install WordPress.
If the database name, user name, and password settings in wp-config.php are correct and you get a “Database Connection Error” message, change the settings in wp-config.php to
define( ‘WP_DEBUG’, true ); change it to true and check the part of the message that is displayed.
In most cases, this is due to a misconfiguration, but in some cases you may need to change the following
In wp-config.php, on line 38, where the hostname is setdefine( ‘DB_HOST’, ‘localhost’);
First, find out where mysql.sock is installed.
In this case, the file is installed in /var/lib/mysql/mysql.sock, so change it as followsdefine( ‘DB_HOST’, ‘localhost:/var/lib/mysql/mysql.sock’);

タイトルとURLをコピーしました