Install MySQL

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

1, Download the MySQL 5.6.13 Source Code version

  http://dev.mysql.com/downloads/mysql/#downloads

  Upload to the server's /softs directory

2, Check if the MySQL is installed  

[root@h2 ~]# rpm -qa | grep mysql
qt-mysql-4.6.2-25.el6.x86_64
mysql-libs-5.1.66-2.el6_3.x86_64
mysql-5.1.66-2.el6_3.x86_64
mysql-server-5.1.66-2.el6_3.x86_64
[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_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/db/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306

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
/usr/local/mysql
[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
PATH=$JAVA_HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
[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;
Bye

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