mysql5.6 install
Here, the pre compiled binary is used for installation and deployment. Compared with the compiled installation, it does not need to be compiled, but can be used after the initialization of my.cnf is modified directly. It is recommended to use this method in the production environment.
- Download File
Domestic image source download faster, there is no need to go to the official website to download.
cd ~ wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
- Configuration file preparation here only configures the necessary parameters for installation and startup. Production level parameters are not described here.
cat /etc/my.cnf [client] port = 3306 socket = /data/coohua/mysql/mysql.sock default-character-set = utf8 [mysqld] port = 3306 socket = /data/coohua/mysql/mysql.sock basedir = /app/3rd/mysql/mysql datadir = /data/coohua/mysql/data/ pid-file = /data/coohua/mysql/data/mysqld.pid user = mysql character-set-server =utf8 innodb_large_prefix=on lower_case_table_names = 1 server-id = 1
- Create MySQL user
groupadd mysql useradd -g mysql -M -s /sbin/nologin mysql
- Create mysql directory
mkdir -p /app/3rd/mysql mkdir -p /data/coohua/mysql
- Preparation before installation
tar -zxf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz -C /app/3rd/mysql/ ln -s /app/3rd/mysql/mysql-5.6.39-linux-glibc2.12-x86_64 /app/3rd/mysql/default chown -R mysql.mysql /app/3rd/mysql #Program directory chown -R /data/coohua/mysql/ #Data directory
- Initialize installation
cd /app/3rd/mysql/mysql-5.6.39-linux-glibc2.12-x86_64 ./scripts/mysql_install_db --defaults-file=/app/3rd/mysql/default/my.cnf --user=mysql
- The following error message appears
please install the following Perl modules before executing scripts/mysql_install_db:
autoconf missing
yum -y install autoconf
error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
Lack of libaio
yum install -y libaio
- Reinitialize
./scripts/mysql_install_db --defaults-file=/app/3rd/mysql/default/my.cnf --user=mysql
- service mysql start
/app/3rd/mysql/default/bin/mysqld_safe --defaults-file=/app/3rd/mysql/default/my.cnf --user=mysql &
- Change Password
./bin/mysqladmin -S /tmp/mysql.sock -u root -h localhost password 'root'
- Safety reinforcement
mysql -S /tmp/mysql.sock -uroot -hlocalhost -proot delete from mysql.user where password=''; #Delete user without password drop database test; #Delete test database
So far, MySQL 5.6 has been installed, but only after installation, there will be a lot of optimization in the future.