Centos7 Mysql5.7.27 binary installation

Step a: downloading the installation package, open Mysql official website, find the corresponding

Download path is as follows: https://downloads.mysql.com/archives/community/

wget https://downloads.mysql.com/archives/get/file/mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz  -O /usr/local/src/mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz

 

Step two: downloading dependencies, Centos7 no installation comes

 

[centos702 the root @ 21 is : 56 is : . 19 ]: / usr / local / the src 
# yum -Y the install libaio 
loaded plug: fastestmirror, Langpacks 
Loading Mirror SPEEDS cached from the hostfile
  * Base: mirrors.aliyun.com
  * EPEL: mirrors.aliyun .com
  * Extras: mirrors.aliyun.com
  * the Updates: mirrors.aliyun.com 
package libaio - 0.3 . 109 - 13 .el7.x86_64 installed and the latest version 
without any treatment

Step Three: extracting installation package

[root@centos702 21:58:45]:/usr/local/src
#tar -zxvf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz 

Step Four: Create a database user, move the database files to the location you want to put, and to create a mysql data directory, last modified owner as Mysql

[root@centos702 21:59:26]:/usr/local/src
#useradd -M -s /sbin/nologin -r mysql
#mv /usr/local/src/mysql-5.7.27-linux-glibc2.12-x86_64 /home/data/mysql [root@centos702
22:02:09]:/usr/local/src #mkdir -p /home/data/mysql [root@centos702 22:02:18]:/usr/local/src #chown -R mysql.mysql /home/data/mysql

Step Five: initialize the database

[root@centos702 22:04:56]:/home/data
#/home/data/mysql/bin/mysqld --initialize --user=mysql --basedir=/home/data/mysql --datadir=/home/data/mysql/data
2019-11-09T14:06:56.634380Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-11-09T14:06:57.063698Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-11-09T14:06:57.142365Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-11-09T14:06:57.200813Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 30cc7a37-02fa-11ea-a548-000c29cbc202.
2019-11-09T14:06:57.202254Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed ' CAN BE Not the Opened.
 2019 - . 11 -09T14: 06 : 57 is .203612Z . 1 [Note] A Temporary Generated IS password for the root @ localhost: KaELVb2yol < . 4 # The temporary password is generated for the first time landing, need to re-edit after landing

Step Six: Create a profile, create a profile only common here

cat > /etc/my.cnf <<EOF
[mysqld]
basedir=/home/data/mysql
datadir=/home/data/mysql/data
port=3306
socket=/home/data/mysql/mysql.sock
character-set-server=utf8
log-error=/var/log/mysqld.log
pid-file=/tmp/mysqld.pid
[mysql]
socket=/home/data/mysql/mysql.sock
[client]
socket=/home/data/mysql/mysql.sock
EOF

Step 7: Configuring environment variables, and refresh

cat >/etc/profile.d/mysql.sh <<EOF
export PATH=/home/data/mysql/bin:\$PATH
EOF
source /etc/profile.d/mysql.sh

Step Eight: startup script generation, and start the mysql

[root@centos702 22:14:40]:/home/data
#cp /home/data/mysql/support-files/mysql.server /etc/init.d/mysql
[root@centos702 22:16:42]:/home/data
#chmod +x /etc/init.d/mysql
[root@centos702 22:17:55]:/home/data #vim /etc/init.d/mysql
# Modify mysql startup configuration file, and the specified datadir basedir path, if not specified, the default is / usr / local / mysql 
[centos702 the root @ 22 is : 18 is : 31 is ]: / Home / Data 
# Sed -i ' 46S basedir = # # = the basedir / Home / Data / MySQL # ' /etc/init.d/ MySQL 
[centos702 the root @ 22 is : 20 is : 15 ]: / Home / Data 
# Sed -n ' 46p ' /etc/init.d/ MySQL 
the basedir = / Home / Data / MySQL 
[centos702 the root @ 22 is : 20 is : 30 ]: / Home /data
#sed -i '47s#datadir=#datadir=/home/data/mysql/data#' /etc/init.d/mysql 
[root@centos702 22:21:13]:/home/data
#sed -n '47p' /etc/init.d/mysql 
datadir=/home/data/mysql/data
#启动mysql
[root@centos702 22:23:54]:/home/data
# /etc/init.d/mysql start
Starting MySQL. SUCCESS! 

Step 9: Log mysql, and change passwords

[root@centos702 22:26:28]:/home/data
#mysql -uroot -p'KaELVb2yol<4'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.27

Copyright (c) 2000, 2019, 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> set password for root@localhost=password('cnhope');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/cnhope/p/11828190.html