Tuesday, July 4, 2023

.::: How To Install MySQL 8 on CentOS 7 :::.


1. download repository
https://dev.mysql.com/downloads/repo/yum/
wget https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm

[root@teguhth data]# wget https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm
--2023-07-03 14:27:10--  https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.201.152.213
Connecting to repo.mysql.com (repo.mysql.com)|23.201.152.213|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11196 (11K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el7-7.noarch.rpm’

100%[========================================================================================================================>] 11,196      --.-K/s   in 0.005s

2023-07-03 14:27:12 (2.11 MB/s) - ‘mysql80-community-release-el7-7.noarch.rpm’ saved [11196/11196]

[root@teguhth data]# ls
mysql80-community-release-el7-7.noarch.rpm
[root@teguhth data]#


2. Install repository
[root@teguhth data]# rpm -ivh mysql80-community-release-el7-7.noarch.rpm
warning: mysql80-community-release-el7-7.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el7-7  ################################# [100%]
[root@teguhth data]#

3. install MySQL 8.0

[root@teguhth data]# yum install mysql-server -y

4. start MySQL Service

[root@teguhth data]# systemctl start mysqld
[root@teguhth data]# systemctl enable mysqld
[root@teguhth data]#

5. get temporary password
[root@teguhth data]# grep 'temporary password' /var/log/mysqld.log
2023-07-03T07:33:37.739204Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: i!+eTK-qa9Uz
[root@teguhth data]#


6. setting root password
[root@teguhth data]# mysql_secure_installation

7. Test login & version
select @@hostname,@@version;
 
[root@teguhth data]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@teguhth data]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, 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>

mysql> select @@hostname,@@version;
+------------+-----------+
| @@hostname | @@version |
+------------+-----------+
| teguhth01  | 8.0.33    |
+------------+-----------+
1 row in set (0.00 sec)

mysql>
 


8. chek rpm
[root@teguhth ~]# rpm -qa | grep -i 'mysql'
mysql80-community-release-el7-7.noarch
mysql-community-common-8.0.33-1.el7.x86_64
mysql-community-client-8.0.33-1.el7.x86_64
mysql-community-icu-data-files-8.0.33-1.el7.x86_64
mysql-community-server-8.0.33-1.el7.x86_64
mysql-community-client-plugins-8.0.33-1.el7.x86_64
mysql-community-libs-8.0.33-1.el7.x86_64
mysql-community-libs-compat-8.0.33-1.el7.x86_64
[root@teguhth ~]# rpm -qa | grep -i '^mysql'
mysql80-community-release-el7-7.noarch
mysql-community-common-8.0.33-1.el7.x86_64
mysql-community-client-8.0.33-1.el7.x86_64
mysql-community-icu-data-files-8.0.33-1.el7.x86_64
mysql-community-server-8.0.33-1.el7.x86_64
mysql-community-client-plugins-8.0.33-1.el7.x86_64
mysql-community-libs-8.0.33-1.el7.x86_64
mysql-community-libs-compat-8.0.33-1.el7.x86_64
[root@teguhth ~]#

9. Additional for install MySQL 8
 UNINSTALL COMPONENT 'file://component_validate_password';
mysql> UNINSTALL COMPONENT 'file://component_validate_password';
ERROR 3537 (HY000): Component specified by URN 'file://component_validate_password' to unload has not been loaded before.
mysql>

UNINSTALL COMPONENT 'file://component_validate_password';
SET GLOBAL validate_password.policy = 0;   # For LOW
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
FLUSH PRIVILEGES;

set global validate_password.policy = LOW;
set global validate_password.length = 2;
set global validate_password.mixed_case_count = 0;
set global validate_password.number_count = 0;
set global validate_password.special_char_count = 0;
 
MySQL 8.0
CREATE USER 'replica'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'replica'@'%' WITH GRANT OPTION;
GRANT replication slave on *.* TO 'replica'@'%' WITH GRANT OPTION;
flush privileges;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
UPDATE mysql.user SET host='%' WHERE user='root';
 
10. fix from lab. disable validation password
 after uninstall component

 UNINSTALL COMPONENT 'file://component_validate_password';
dd  
 
runn again . setting root password with disable validation password
[root@teguhth data]# mysql_secure_installation


[root@teguhth02 ~]# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: n
Using existing password for root.

Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 ... skipping.
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
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
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
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.

All done!
[root@teguhth02 ~]#

No comments:

Post a Comment

Popular Posts