Environment: CentOS7 Software: MySQL5.6.26
It is recommended to run the following command before installation to configure the required environment:
yum install libaio #Install libaio
yum install deltarpm #Install deltarpm
yum install perl-Data-Dumper.x86_64 #Install Perl modules
1 Download MySQL source package
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
2 Unzip the downloaded file to the /usr/local directory and modify the folder name to mysql
tar -zxvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz -C /usr/local
mv mysql-5.6.26-linux-glibc2.5-x86_64/ mysql
3 Create Mysql user and user group
useradd mysql -s /sbin/nologin
4 Create a Mysql database directory and grant permissions to Mysql users
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
chown -R mysql:mysql /usr/local/mysql
5 Enter the /usr/local/mysql directory to initialize mysql
. /scripts/mysql_install_db --user=mysql --datadir=/data/mysql
6 Back up the my.cnf file that comes with the system, and then move the default configuration file in the Mysql decompression directory.
mv /etc/my.cnf /etc/my.cnf.bak
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
7 Modify the my.cnf file
datadir=/data/mysql
port=3306
socket=/tmp/mysql.sock
8 Copy the mysql.server file in the unzipped directory to /etc/init.d/mysqld
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod 755/etc/init.d/mysqld
vi /etc/init.d/mysqld
datadir=/data/mysql #Modify the database directory file
basedir=/usr/local/mysql
9 Start mysql service
service mysqld start
Usage: mysqld {start|stop|restart|reload|force-reload|status}[ MySQL server options ]
10 Configure mysql environment variables
echo "PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
source /etc/profile
11 Log in to mysql
[ root@localhost ~]# mysql -uroot -p #No password is required for the first login, just press enter
Enter password:
Welcome to the MySQL monitor. Commands end with; or \g.
Your MySQL connection id is 2
Server version:5.6.26 MySQL Community Server(GPL)Copyright(c)2000,2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
mysql> update mysql.user set password=password("123456") where user="root"; #Modify root password
flush privileges;
12 Set character encoding to UTF-8
Please refer to: The modified character set encoding of MySQL 5.5/5.6 under Linux is UTF8. The installation is complete.
Recommended Posts