Install mysql5.7 using centos 7 rpm

Source: Internet
Author: User

Install mysql5.7 using centos 7 rpm
Step 1: Download mysql

Use the wget command on the Linux terminal to download network resources:

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

1: Check whether MySQL is installed locally

rpm -qa | grep mysql

2: uninstall the previous mysql

Full name of an existing MySQL instance in rpm-e
Step 2: Decompress the file

Next, go to the moved directory.cd /usr/localAnd decompress

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

To facilitate subsequent operations, you can change the decompressed file name to mysql:

mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
Step 3: configure the Startup File

Then gomysqlOfsupport-filesDirectory

1. Copy my.cnfTo /etc/my.cnf(Mysqld is automatically read at startup)
cp my-default.cnf /etc/my.cnf

Note: If you have installed the default mysql at the same time on the Linux virtual machine during installation, the terminal will prompt you whether the file already exists and overwrite it by entering yes.

2. Configure database Encoding
vi /etc/my.cnf

Add the following configuration information to this file (if any)

[mysql]default-character-set=utf8[mysqld]default-storage-engine=INNODBcharacter_set_server=utf8
3. Copy mysql.serverTo /etc/init.d/Directory [Purpose: To achieve automatic execution upon startup]

Run the following command (mysql is the service name ):

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

Give two directory locations

basedir=/usr/local/mysqldatadir=/usr/local/mysql/data
5. Create a special user who operates the database for security and convenience

> 1 ),groupadd mysql# Create a mysql group> 2 ),useradd -r -g mysql mysql# Create a mysql user and put the user in the mysql group> 3 ),passwd mysql# Set a password for the mysql user 4 )./usr/local/mysqlChange ownerchown -R mysql:mysql /usr/local/mysql/

Step 4: Initialize the mysql database

First gomysqlOfbinDirectory

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

Generate a data Directory, which indicates that the database has been initialized successfully and the mysql root User has generated a temporary password:***(It is best to record this temporary password first)

2. encrypt the database
./mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
3. Start mysql (to prevent the process from getting stuck, you can add & indicates that the process runs in the background after the mysql Command is started)
./mysqld_safe --user=mysql &
4. Checkps -ef|grep mysql

If a process is found, the startup is successful.

Step 5: Enter the client 1. log on:
./Mysql-uroot-p # p and enter the previous temporary password
2. Change the password
Set password = password ('new password ');
Step 6: Set Remote Access 1. Before remote access, open the centos7 port: 1): Enable the 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 remote access username @ '%' identified by 'user password ';Mysql>select host,user from user;[One more remote logon user record] mysql>flush privileges;(Refresh)

Now you can use a remote machine for access!

Resolution: Use the mysql-h Host ip address-u username-p password for remote access

Step 7: Set auto-start upon startup 1. Add the mysql Service

chkconfig --add mysql[Mysqld-install]

2. Set mysql service to automatic

chkconfig mysql on

3. Restart to view the process
init 6
ps -ef|grep mysql
Step 8: Configure Environment Variables

To facilitate the operation, it is necessary to configure environment variables.

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

Summary: The basic configuration in this step is complete.

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.