MySQL installation method

Source: Internet
Author: User
Tags mysql in

MySQL installation tutorial under Linux CENTOS7 Environment

Fate Acquaintance-(like-minded) font: [Increase decrease] Type: Reprint time: 2017-03-17 I want to comment

This article mainly for you in detail the Linux CENTOS7 environment MySQL installation tutorial, with a certain reference value, interested in small partners can refer to

Detailed introduction to installing MySQL steps in Linux centos7 environment

Install MySQL

MySQL has two different places from windows

1), My.ini Save to/etc/my.ini

2), user rights, individual user execution

First, to find out if MySQL was previously installed, use the following command:

Rpm–qa | Grep-i MySQL

If the following package is displayed, the MySQL is installed

mysql-4.1.12-3.rhel4.1

mysqlclient10-3.23.58-4.rhel4.1

Download MySQL Unpacking package

Mysql-5.7.17-linux-glibc2.5-x86_64.tar (download to http://mirrors.sohu.com website)

Website: http://mirrors.sohu.com/mysql/MySQL-5.7/

can also be downloaded under the Linux operating system, enter the following command

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

Create a directory software for the MySQL package that we will download later, go to the Directory Input command first:cd/software

After the download is complete, you will see a copy of the MySQL installation package file in the software directory

Third, the establishment of users, as well as the MySQL directory

1, Groupadd MySQL #建立一个mysql的组

2, Useradd-r-G mysqlmysql #建立mysql用户, and put the user into the MySQL group

3, passwd MySQL #给mysql用户设置一个密码

Iv. unpacking the MySQL installation package

1, first move the tar.gz package to the/usr/local directory, enter the command

Mv/software/mysql/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz/usr/local

2, Decompression tar.gz bag

First go to the/usr/local directory, enter the command cd/usr/local

Decompression command tarzxvfmysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

Enter View Directory command ll

You'll find out more catalogs mysql-5.7.17-linux-glibc2.5-x86_64

Note: There is no data directory, the My.ini file is in the Support-files directory

3. Change the catalogue name to/usr/local/mysql

(This is the default installation directory for MySQL under Linux)

Change the extracted file name to MySQL

Input command: MV mysql-5.7.17-linux-glibc2.5-x86_64 MySQL

V. Configuration-related boot configuration files

The first thing to do is to go to the support-files/file directory

Input command: CD support-files/

1. Copy my.cnf to/ETC/MY.CNF (automatically read when MySQL starts)

Enter Command cpmy-default.cnf/etc/my.cnf

2, solve garbled problem

Input command:vi/etc/my.cnf (enter editable state)

Change:

[MySQL]

Default-character-set=utf8 (indicates troubleshooting client garbled issues)

[Mysqld]

Default-storage-engine=innodb

Character_set_server=utf8 (indicates troubleshooting service-side garbled issues)

3, copy Mysql.server to/etc/init.d/directory "purpose to achieve mysqld-install such boot automatic execution effect"

Input command CP mysql.server/etc/init.d/mysql (MySQL is the service name)

Note: The/etc/init.d/directory, equivalent to registry Hkey_local_machine\system\controlset001\services Records, has those services

4. Modify/etc/init.d/mysql Parameters

Enter Command vi/etc/init.d/mysql

Given with two directory locations

Basedir=/usr/local/mysql

Datadir=/usr/local/mysql/data

5, to the directory/usr/local/mysql change owner

Input command chown-r mysql:mysql/usr/local/mysql/

Vi. initializing the MySQL database

1. Initialize MySQL

mysql_install_db (old version of the procedure)

New version: Initialization

Enter the command ./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: (record the temporary password XXX)

2. Encrypt the database

Enter the command ./mysql_ssl_rsa_setup--datadir=/usr/local/mysql/data

3. Start MySQL

Enter the command ./mysqld_safe--user=mysql & (& commit to run MySQL service in the background)

Vii. entering the client

1. Login

Enter the command ./mysql-uroot-p

And then enter your temporary password.

2. Change the password

Input command set Password=password (' xxxx ')

Eight, window remote access to the Linux virtual machine MySQL

Let's take a look at the database structure

1. Turn off the firewall (or open the port to the firewall) so that window can connect

Input command systemctl stop Firewalld.service

2. Authorization to Windows

Input command mysql>grant all privileges on * * [email protected] '% ' identified by ' 123456 ';

"One more Telnet user record"

Mysql>flush privileges;

3. Remotely link the database, or restart (init 6).

Input command:mysql–hip address-uroot-p123456

Nine, set the boot automatically start the MySQL service

1. Add MySQL Service

Input command chkconfig--add mysql "Mysqld-install"

2. Set up MySQL service for automatic

Input command chkconfig MySQL on

3. Restart Check

Init 6ps–ef | grep MySQL

X. Setting path

Enter Command vi/etc/profile

Input command exportpath= $JAVA _home/bin:/usr/local/mysql/bin: $PATH

After we have configured the MySQL environment variable, we will not have to go to the/usr/local/mysql/bin directory to log in, and now we can login MySQL in any directory.

Here we have successfully installed MySQL in the Linux CENTOS7 environment.

Thank you Bo friends for their support!

The above is the whole content of this article, I hope that everyone's learning has helped, but also hope that we support the script home.

MySQL installation method

Related Article

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.