In CentOS 7 Linux MariaDB is by default installed, due to this you may face issue installing MySQL. If you want to install MySQL, first you should remove the existing MariaDB. MariaDB is a refraction of MySQL

Step 1 : Remove Maria DB completely

  • yum -y remove mariadb-libs

Step 2: Install MySQL 5.7

  • sudo wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
  • sudo yum localinstall mysql57-community-release-el7-7.noarch.rpm
  • sudo yum repolist enabled | grep “mysql.*-community.*”
  • sudo yum install mysql-community-server
  • sudo yum-config-manager –enable mysql57-community
  • sudo yum-config-manager –disable mysql56-community
  • sudo service mysqld start
  • sudo service mysqld status
  • mysql –version

Step 3 : Get root temporary password

  • grep ‘temporary password’ /var/log/mysqld.log

Step 4 : Show password complexity rule

  • SHOW VARIABLES LIKE ‘validate_password%’;

Step 5 : Set password complexity rule to low if required

  • Add validate_password_policy=LOW to /etc/my.cnf file OR
  • SET GLOBAL validate_password_policy=LOW; in > mysql
  • uninstall plugin validate_password;

Step 6 : Login to mysql command line

  • mysql -u root -p

Step 7 : Change root password

  • ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘<password>’;
  • FLUSH PRIVILEGES;

Step 8 : Bind the IP addresss

  • Edit /etc/mysql/my.cnf
  • Change the bind-address from 127.0.0.1 to the ifconfig eth(0) inet addr (e.g. 192.168.1.211)
  • restart mysql service

Step 9 : Install mysql java connector if required

  • sudo yum install -y mysql-connector-java
  • ls /usr/share/java/mysql-connector-java.jar