Part Ⅰ Lost in MariaDB
1. Install Mysql using yum
Type in ‘yum install mysql’
Type in ‘yum list installed | grep -i mysql’, but return nothing…Does Mysql NOT installed correctly? Actually, one database named MariaDB is installed rather than that Mysql what we want.
2. Brief to MariaDB
As wikipedia says, ‘MariaDB is a community-developed fork of the MySQL relational database management system intended to remain free under the GNU GPL. It is notable for being led by the original developers of MySQL, who forked it due to concerns over its acquisition by Oracle.’, so MariaDB is treated as an alternative to Mysql.
However, we don’t need it and clean it before installing the right Mysql.
3. Remove MariaDB
Type in ‘yum list installed | grep -i mariadb’, which will get two packages prefixed with ‘mariadb’
Type in ‘yum remove <name prefixed with mariadb-libs>, result as shown below:
Part Ⅱ Install Oracle Mysql
1. Download Mysql RPM
Go to mysql official website (http://www.mysql.com/), and find ‘yum repository’ page to scroll down to select ‘Red Hat Enterprise Linux 7 / Oracle Linux 7 RPM package’, click download button at right side, then right click ’No thanks, just start my download’ to get noarch rpm download link on appearing page.
2. Import Mysql RPM and Install Mysql
Type ‘wget <mysql noarch rpm url>’.
Next, type in ‘sudo rpm -ivh <mysql noarch rpm>’ to add mysql repo resources to yum list.
Type in ‘yum install mysql-server’ to start install mysql, input ‘y’ if prompt appears.
3. Configure Mysql
Type in ‘sudo chown -R root:root /var/lib/mysql’ to resolve limits of access permission ( if ‘ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ appears)
(If you are not sure the running account, type whoami or who -p)
Type in ‘mysql’ or ‘mysql -u root -p’ even if password is correct, you will get error message ‘ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)’, because Mysql has set default password for root user. Type in ‘sudo grep ‘temporary password’ /var/log/mysqld.log’ to get default password, then use it to login in.
Next, to run Mysql normally, it is essential to change default password. The default password validation policy is upper case, lower case, number and special character, so the new password should contain all of these listed, otherwise it will show error message ‘ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.’. Type ‘SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘<new password>’);’ to change it.
Openning 3306 port
vi + /etc/sysconfig/iptables
-A INPUT -p tcp -m state –state NEW -m tcp –dport 3306 -j ACCEPT
service iptables restart