Linux in mysql installation (Source installation)

This article describes the manner source installation is compiled and installed Mysql 5.6 (installation path can be specified), or may not use the source installation, directly with the installation package.

Source installation with caution, easy error.

1. Uninstall the old version

-qa RPM | grep MySQL         check for older versions

Query results: MySQL -libs-5.1.73-7 .el6.x86_64

RPM -e mysql- libs             remove the old version of the
 RPM -e MySQL-libs - nodeps    forcibly removed

2. Install mysql

1. Install the source code needs to be compiled

Download c compiler tool
yum -y install make gcc-c++ cmake bison-devel  ncurses-devel

2. Upload a local source package mysql to / opt

Use xftp connection to upload

3. Compile

-zxvf MySQL 5.6.14-tar .tar.gz decompression
MySQL cd -5.6.14                       Change directory

Compile preparation:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

Compile and install:
make && make install

Configuring mysql

authority management:

1 Create mysql group, and user
    groupadd mysql
    useradd -g mysql mysql
    
2. Modify the / usr / local / MySQL permissions
    chown -R mysql:mysql /usr/local/mysql
    
    
Initial Configuration:
1.cd /usr/local/mysql
2.scripts/mysql_install_db

When you start MySQL service will be first in looking my.cnf / etc directory, the search will not find " $ basedir / my.cnf " , in this case is / usr / local / MySQL / my.cnf

View / whether there is etc my.cnf, we have to change the name to prevent interference
 1.mv /etc/my.cnf / etc / my.cnf.bak

Add Service (mysql service into the / etc / init.d), and set the boot from the start:
 1.CP /usr/local/mysql/support-files/mysql.server /etc/init.d/ MySQL
 2 .chkconfig MySQL ON
 3 .service MySQL Start

Configuration environment variable:
1.vi / etc / Profile
 2 . Join in the file:
    export PATH=$PATH:/usr/local/mysql/bin
3.source /etc/profile

Guess you like

Origin www.cnblogs.com/wangcuican/p/12074603.html