Install mysql5.7 in CENTOS7 offline mode

Source: Internet
Author: User

First step: Download MySQL

Download network resources using the wget command on the Linux Terminal: (Can be good first)

wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
    • 1

1: Check if MySQL is already installed locally

| grep mysql
    • 1

2: Uninstall the previous MySQL

-e 已经存在的MySQL全名
    • 1
Step two: Unzip the file

Next go to the directory after the move cd /usr/local , then unzip

tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar
    • 1

After decompression in order to facilitate the subsequent operation can be extracted after the filename modified to MySQL:

mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
    • 1
Step Three: Configure the startup file

And then go to mysql the support-files directory

1. Copy my.cnfTo /etc/my.cnf(Automatically read when mysqld starts)
cp my-default.cnf /etc/my.cnf

Note: If you install the Linux virtual machine at the same time when the default MySQL, the above steps, the terminal will prompt you whether the file is overwritten, enter Yes overwrite.

2. Configure Database encoding
vi /etc/my.cnf

In this file, you can add the following configuration information (if you have any modifications)

[mysql]default-character-set=utf8[mysqld]default-storage-engine=INNODBcharacter_set_server=utf8
3. Copy mysql.serverTo /etc/init.d/Directory "Purpose to achieve power-on automatic execution effect"

Execute the command (MySQL is the service name):

cp mysql.server /etc/init.d/mysql 
4. Modification /etc/init.d/mysqlParameters
vi /etc/init.d/mysql

Given with 2 directory locations

basedir=/usr/local/mysqldatadir=/usr/local/mysql/data
5, for security convenience, create an operational database of specialized users

>1), groupadd mysql #建立一个mysql的组
>2), useradd -r -g mysql mysql #建立mysql用户, and put the user in the MySQL group
>3), passwd mysql #给mysql用户设置一个密码
4), to the directory /usr/local/mysql change ownerchown -R mysql:mysql /usr/local/mysql/

Fourth step: Initializing the MySQL database

First go to mysql the bin directory

1. Initialization
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

Generate a data directory that represents the successful initialization of the database
and the root user of MySQL generates a temporary password:* * *(preferably log this temporary password first)

2. Encrypt the database
./mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
3. Start MySQL (in order to keep the process card master, you can add & for this process to run in the background after starting the MySQL command)
./mysqld_safe --user=mysql &
4. Check ps -ef|grep mysql

The discovery of a process represents a successful start.

Fifth Step: Enter the client 1. Login:
./mysql -uroot -p    #p后输入之前的临时密码
2. Change the password
set password=password(‘新密码‘);
Sixth step: Set up remote access 1, you need to open CENTOS7 port before remote access: 1): Open port:
firewall-cmd --zone=public --add-port=3306/tcp --permanent
2): Restart the firewall:
firewall-cmd --reload
2, Authorization

Mysql> grant all privileges on *.* to 远程访问用户名@‘%‘ identified by ‘用户密码‘;
Mysql> select host,user from user; "1 more telnet user records"
Mysql> flush privileges; (Refresh)

You can use the remote machine to access it now!

Resolution: Remote access with MYSQL-H host Ip-u user name-p password

Seventh step: Set boot from boot 1, add service MySQL

chkconfig --add mysql"Mysqld-install"

2. Set up MySQL service for automatic

chkconfig mysql on

3. Restart the viewing process
init 6
ps -ef|grep mysql
Eighth Step: Configure environment variables

For ease of operation, it is necessary to configure environment variables.

vi /etc/profileexport PATH=$JAVA_HOME/bin:/usr/local/mysql/bin:$PATH

Install mysql5.7 in CENTOS7 offline mode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.