CentOS 7.5 binary installation MySQL-5.6.40

Installation dependency

yum install -y gcc gcc-c++ automake autoconf
yum -y install cmake bison-devel ncurses-devel libaio-devel

mysql-5.6.40 binary package download address

https://downloads.mysql.com/archives/get/file/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz

1. Download MySQL-5.6.40 binary package

[root@7-test1 ~]# wget https://downloads.mysql.com/archives/get/file/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz

2. Extract mysql binary package to / usr/local

[root@7-test1 ~]# tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz -C /usr/local

3. Modify name and make soft connection

[root@7-test1 ~]# cd /usr/local
[root@7-test1 local]# mv mysql-5.6.40-linux-glibc2.12-x86_64 mysql-5.6.40
[root@7-test1 local]# ln -s mysql-5.6.40 mysql

4. Create mysql users and groups

//Create mysql group

[root@7-test1 local]# groupadd mysql

//Create mysql user

[root@7-test1 local]# useradd -g mysql -s /bin/false mysql

5. Copy the master profile

//Backup / etc/my.cnf

[root@7-test1 local]# mv /etc/my.cnf /etc/my.cnf.old

//Copy master profile

[root@7-test1 ~]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

6. Copy the startup script

[root@7-test1 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

7. Initialize mysql

//Enter / usr/local/mysql/scripts

[root@7-test1 ~]# cd /usr/local/mysql/scripts

//Install dependency package before initialization

[root@test1 scripts]# yum -y install autoconf

//Initialize mysql

[root@7-test1 scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

--user      #Specify mysql user

--basedir       #Specify mysql installation directory

--datadir       #Specify mysql data directory

Initialization error

[root@7-test1 scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

FATAL ERROR: please install the following Perl modules before executing ./mysql_install_db:

Data::Dumper

Reason: autoconf dependency package missing

Solution

[root@7-test1 scripts]# yum -y install autoconf

8. Add mysql command environment variable

//Export mysql command environment variables

[root@7-test1 scripts]# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh

//Make configuration effective

[root@7-test1 scripts]# source /etc/profile

9. Configure systemd to manage mysql

[root@7-test1 scripts]# vim /etc/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000

10. Start mysql and check the startup

//Start mysql

[root@7-test1 scripts]# systemctl start mysqld ; systemctl enable mysqld

[root@7-test1 scripts]# netstat -ntpl  | grep 3306

tcp6       0      0 :::3306                 :::*                    LISTEN      31349/mysqld  

11. Enter mysql and set password

//Set mysql password

mysql> set password=password('123');

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

Tags: Linux MySQL yum cmake

Posted on Tue, 03 Dec 2019 16:29:20 -0800 by wemustdesign