Install Mysql on CentOS

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:

1

2

 

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.

3

4

5

    2. Import Mysql RPM and Install Mysql

Type ‘wget <mysql noarch rpm url>’.

6

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.

7

    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.

8

9

10

Openning 3306 port
vi + /etc/sysconfig/iptables
-A INPUT -p tcp -m state –state NEW -m tcp –dport 3306 -j ACCEPT
service iptables restart
All done

 

 

 

 

 

Install Mysql on CentOS

Download & Install Tomcat on CentOS

    1. Get URL from tomcat official website

1 2

    2. Download and Start tomcat

        tar -zxvf apache-tomcat-9.0.0.M4.tar.gz
        mv ./apache-tomcat-9.0.0.M4 /usr/local/tomcat9
        (run/stop tomcat)
        /usr/local/tomcat9/bin/startup.sh
        /usr/local/tomcat9/bin/shutdown.sh
        (change port)
        vi + /etc/sysconfig/iptables
        -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT
       service iptables restart

    3. Config Tomcat

    Type in ‘cd /usr/local/tomcat/conf’
    Type in ‘vim server.xml’
    Edit server.xml by typing ‘i’, firstly change port of “<Connector port=“8080” protocol=“HTTP/1.1” from 8080 to 80, then add “<Context path=”” docBase=“ashton/” reloadable=”true” debug=”0″></Context>” into <host></host>, which directory ‘ashton’ is under webapps, use absolute path if directory is not under webapps.

    4. Start Tomcat Server

    Type in ‘/usr/local/tomcat9/bin/startup.sh’

    5.Type <your ip address> to web browser

3
Download & Install Tomcat on CentOS