Saturday, January 7, 2017

MYSQL Installation on CentOS 7

MYSQL Server 5.7.17 Installation on CentOS 7 
-----------------------------------------------------------------------

Download / Copy mysql57-community-release-el7-9.noarch.rpm to /opt folder

1.  sudo yum localinstall mysql57-community-release-el7-9.noarch.rpm
  
2. sudo yum install mysql-community-server

3. sudo service mysqld start
4. sudo service mysqld status

6. sudo grep 'temporary password' /var/log/mysqld.log
   A temporary password is generated for root@localhost: _D#p,Sjid5Zb

7. mysql -uroot -p
   > _D#p,Sjid5Zb [put temporary password]

8. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mpassword1212!';



8.   mysql -h localhost -u root -p [use password Mpassword1212!]

Note: To disable  password validate plugin

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPa$$123456789';

mysql> uninstall plugin validate_password;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxx'; [new password]


10. CREATE DATABASE projects;
11. CREATE USER 'dbuser1'@'%' IDENTIFIED BY 'Dbuser@123';
12. GRANT ALL ON projects.* TO 'dbuser1'@'%';
13. flush privileges;

sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
$ sudo firewall-cmd --reload

$ sudo firewall-cmd --list-all  
 
 
 
 Mysql Service Start
------------------------------- 
 sudo systemctl start mysqld
 or 
 sudo service mysqld start
 sudo service mysqld stop


mysql config file 
--------------------------
sudo vi /etc/my.cnf

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
port=3306
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
bind-address=1.2.3.4


mysql log file
----------
tail -100f /var/log/mysqld.log  
 
 
 
CREATE DATABASE projects;


CREATE USER 'projuser1'@'%' IDENTIFIED BY 'password';


GRANT ALL ON projects.* TO 'projuser1'@'%';

flush privileges;
 
Note: '%' means accessible from any client 
 
 
CREATE USER 'activemq'@'1.2.3.4' IDENTIFIED BY 'password';

GRANT ALL ON activemq.* TO 'activemq'@'1.2.3.4';
 
Note: '1.2.3.4' means accessible from only 1.2.3.4 ip client 
 
flush privileges;
 
DROP USER ‘activemq’@‘1.2.3.4’; 
 

Verify
--------------
mysql -u root -p
use mysql;
select user,host from user; 
 
 
 
 

4 comments:

  1. sudo firewall-cmd --permanent --add-service=http

    sudo firewall-cmd --reload

    sudo firewall-cmd --list-services

    ReplyDelete
  2. firewall-cmd --permanent --add-forward-port=port=80:proto=tcp:toport=28080
    sudo firewall-cmd --reload

    ReplyDelete
  3. sudo ./add-user.sh
    [sudo] password for xxxx:

    What type of user do you wish to add?
    a) Management User (mgmt-users.properties)
    b) Application User (application-users.properties)
    (a): a

    Enter the details of the new user to add.
    Using realm 'ManagementRealm' as discovered from the existing property files.
    Username : xxxxx
    Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
    - The password should be different from the username
    - The password should not be one of the following restricted values {root, admin, administrator}
    - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
    Password :
    WFLYDM0102: Password should have at least 1 non-alphanumeric symbol.
    Are you sure you want to use the password entered yes/no? yes
    Re-enter Password :
    What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[ ]:
    About to add user 'wildfly' for realm 'ManagementRealm'
    Is this correct yes/no? yes
    Added user 'wildfly' to file '/opt/wildfly-10.1.0.Final/standalone/configuration/mgmt-users.properties'
    Added user 'wildfly' to file '/opt/wildfly-10.1.0.Final/domain/configuration/mgmt-users.properties'
    Added user 'wildfly' with groups to file '/opt/wildfly-10.1.0.Final/standalone/configuration/mgmt-groups.properties'
    Added user 'wildfly' with groups to file '/opt/wildfly-10.1.0.Final/domain/configuration/mgmt-groups.properties'
    Is this new user going to be used for one AS process to connect to another AS process?
    e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
    yes/no? yes
    To represent the user add the following to the server-identities definition />

    ReplyDelete
  4. SHOW VARIABLES LIKE 'validate_password%';

    SET GLOBAL validate_password_length = 6;
    SET GLOBAL validate_password_number_count = 0;

    ReplyDelete