Install MySQL

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

1, Download the MySQL 5.6.13 Source Code version

  Upload to the server's /softs directory

2, Check if the MySQL is installed  

[root@h2 ~]# rpm -qa | grep mysql
[root@h2 ~]# 

3, Unloading system installed MySQL

[root@h2 ~]# rpm -e --nodeps mysql

  Or execution:

[root@h2 ~]# yum remove mysql mysql-server mysql-libs

[root@h2 lib]# rm -rf /var/lib/mysql

4, Create a MySQL group and the MySQL user

[root@h2 ~]# groupadd mysql
[root@h2 ~]# useradd -g mysql mysql
[root@h2 ~]# 

5, Create the MySQL installation directory and data storage path

[root@h2 ~]# mkdir /usr/local/mysql
[root@h2 ~]# mkdir /db/mysql/data

6, Install the compiler tool

[root@h2 ~]# yum install -y wget gcc-c++ ncurses-devel cmake make perl

7, Decompression

[root@h2 softs]# tar -zxvf mysql-5.6.13.tar.gz

8, Implementation source code compiler configuration script

[root@h2 mysql-6.6.13]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_DATADIR=/db/mysql/data \
-DMYSQL_USER=mysql \

9, Compile the source code

[root@h2 mysql-6.6.13]# make

10, Installation

[root@h2 mysql-6.6.13]# make install

11, Removal of temporary installation files

[root@h2 mysql-5.6.13]# make clean

12, Modify the MySQL installation directory and data directory for MySQL owners

[root@h2 mysql-5.6.13]# chown -R mysql:mysql /usr/local/mysql
[root@h2 mysql-5.6.13]# chown -R mysql:mysql /db/mysql/data

13, The initialization configuration script, create own database and table

[root@h2 mysql]# cd /usr/local/mysql
[root@h2 mysql]# scripts/mysql_install_db --user=mysql --datadir=/db/mysql/data

14, The startup script to add/etc/init.d

[root@h2 mysql]# pwd
[root@h2 mysql]# cp support-files/mysql.server /etc/init.d/mysql

15, Start MySQL

[root@h2 mysql]# service mysql start
Starting MySQL.. SUCCESS! 
[root@h2 mysql]#

16, To set environment variables

[root@h2 mysql]# vi /etc/profile
[root@h2 mysql]# source /etc/profile

17, For the MySQL root user authorization and password settings

[root@h2 mysql]# mysql -u root
mysql> use mysql;

mysql> grant all privileges on *.* to root@"%" identified by "root";
Query OK, 0 rows affected (0.00 sec)

mysql> update user set Password = password('654321') where User='root';
Query OK, 5 rows affected (0.01 sec)
Rows matched: 5  Changed: 5  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit;

18, Set boot

[root@h2 mysql]# chkconfig mysql on
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Sheryl at December 05, 2013 - 11:21 AM