linux Source Installation mysql5.6.20 Tutorial
- 2021-06-28 14:24:09
- OfStack
The MySQL 5.6 source installation record under linux is as follows
1. Download: Current mysql version to 5.6.20
http://dev.mysql.com/downloads/mysql
Select Source Code
2. Required packages
yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake
3. Compile and Install
Add User
groupadd mysql
useradd -r -g mysql mysql
Compile Installation
tar -zxvf mysql-5.6.20.tar.gz
cd mysql-5.6.20
# Installed by default /usr/local/mysql
cmake .
make && make install
Compile parameters
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
Compiled parameters can be referred to http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html
Change directory owner
chown -R mysql.mysql /usr/local/mysql
4. Initialize the database
cd /usr/local/mysql/scripts
./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
5. Register as a Service
cd /usr/local/mysql/support-files
# Registration Services
cp mysql.server /etc/rc.d/init.d/mysql
# Use default profile
cp my-default.cnf /etc/my.cnf
# Give Way chkconfig Administration mysql service
chkconfig --add mysql
# Start Up
chkconfig mysql on
6. Start MySQL Service
service mysql start
7. Change the encoding to prevent scrambling
SHOW VARIABLES LIKE 'character%'
Modify my.cnf file for mysql
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
[mysql]
default-character-set=utf8
8. Add bin of mysql to path
cd ~
# I will path Added to the current user directory bashrc If global settings are required, modify `/etc/profile`
vi .bashrc
# Add the following
PATH=/usr/local/mysql/bin:$PATH
export PATH
9. Configure user passwords and remote access rights
mysql -uroot
SET PASSWORD = PASSWORD('123456');
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Reference: https://www.ofstack.com/article/102799.htm
Exciting feature sharing: mysql different versions of installation tutorials mysql5.7 Versions of installation tutorials mysql5.6 Versions of installation tutorials