Sunday, May 14, 2023

::: How to Install MariaDB 10.5 or Latest using mariadb_repo (Enable Remote Root) :::.


1. download repository
yum wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
yum install wget -y
wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup

[root@teguhth ]# wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup


2. install repo
chmod +x mariadb_repo_setup
sudo ./mariadb_repo_setup

[root@teguhth yum.repos.d]# chmod +x mariadb_repo_setup
[root@teguhth yum.repos.d]# sudo ./mariadb_repo_setup
# [info] Checking for script prerequisites.
# [info] MariaDB Server version 10.11 is valid
# [info] Repository file successfully written to /etc/yum.repos.d/mariadb.repo
# [info] Adding trusted package signing keys...
/etc/pki/rpm-gpg /etc/yum.repos.d
/etc/yum.repos.d

# [info] Successfully added trusted package signing keys
# [info] Cleaning package cache...
Loaded plugins: fastestmirror
Cleaning repos: base extras mariadb-main mariadb-maxscale mariadb-tools updates
Cleaning up list of fastest mirrors
[root@teguhth yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo          mariadb.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  CentOS-x86_64-kernel.repo  mariadb_repo_setup
[root@teguhth yum.repos.d]#

3. edit mariadb.repo base on your mariadb version (example v 10.5)
[root@teguhth ~]# vi /etc/yum.repos.d/mariadb.repo
[mariadb-main]
name = MariaDB Server
baseurl = https://dlm.mariadb.com/repo/mariadb-server/10.5/yum/rhel/7/x86_64
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY
gpgcheck = 1
enabled = 1

[mariadb-maxscale]
# To use the latest stable release of MaxScale, use "latest" as the version
# To use the latest beta (or stable if no current beta) release of MaxScale, use "beta" as the version
name = MariaDB MaxScale
baseurl = https://dlm.mariadb.com/repo/maxscale/latest/yum/rhel/7/x86_64
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-MaxScale-GPG-KEY
gpgcheck = 1
enabled = 1

[mariadb-tools]
name = MariaDB Tools
baseurl = https://downloads.mariadb.com/Tools/rhel/7/x86_64
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Enterprise-GPG-KEY
gpgcheck = 1
enabled = 1
[root@teguhth yum.repos.d]#


4. install MariaDB Server

[root@teguhth yum.repos.d]# yum install mariadb-server -y
 
yum install nfs-utils htop wget -y
yum install MariaDB-server MariaDB-client MariaDB-shared MariaDB-common rsync -y


5. enable service
[root@teguhth yum.repos.d]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@teguhth yum.repos.d]# systemctl start mariadb


6. check login

[root@teguhth yum.repos.d]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.20-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]>


7. enable mysql_secure_installation

[root@teguhth yum.repos.d]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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 environment.

Remove anonymous users? [Y/n] y
 ... Success!

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? [Y/n] n
 ... skipping.

By default, MariaDB 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 environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

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

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!


8. enable access root
[root@teguhth /]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.5.20-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]>
MariaDB [(none)]> CREATE USER 'root'@'%' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]>

CREATE USER 'root'@'%' IDENTIFIED BY 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;


9. check mysql user
MariaDB [mysql]> use mysql
Database changed
MariaDB [(none)]> select @@hostname, user, host, password, authentication_string from mysql.user;
+------------+-------------+-----------+-------------------------------------------+-------------------------------------------+
| @@hostname | User        | Host      | Password                                  | authentication_string                     |
+------------+-------------+-----------+-------------------------------------------+-------------------------------------------+
| teguhth    | mariadb.sys | localhost |                                           |                                           |
| teguhth    | mysql       | localhost | invalid                                   | invalid                                   |
| teguhth    | root        | %         | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+------------+-------------+-----------+-------------------------------------------+-------------------------------------------+
3 rows in set (0.001 sec)

MariaDB [(none)]>


10. check from MySQL WorkBench

11. check version
MariaDB [(none)]> select @@hostname as Hostname, @@version as Version;
+----------+-----------------+
| Hostname | Version         |
+----------+-----------------+
| teguhth  | 10.5.20-MariaDB |
+----------+-----------------+
1 row in set (0.000 sec)

MariaDB [(none)]>




No comments:

Post a Comment

Popular Posts