CentOS installation MySQL Guide

Source: Internet
Author: User

CentOS installation MySQL Guide

Description: Use the operating system centOS6.4 32-bit system; mysql:mysql-5.7.10-linux-glibc2.5-i686.tar.gz;

First, prepare

Download MySQL

wget http://mirrors.sohu.com/mysql/mysql:mysql-5.7.10-linux-glibc2.5-i686.tar.gz

Note: All shell commands are executed as root user. With the MySQL version of the update, the new version of the installation will be changed, you can refer to the MySQL compressed package install-binary file.

Here I downloaded the mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz under MySQL-5.7.

Second, unzip the file and move to the specified directory

Create a MySQL folder under the home folder as the directory where the MySQL files are stored

[Email protected] ~]# Cd/home

[[email protected] ~]# mkdir MySQL

Go back to the directory where you downloaded the compressed files and extract the compressed files

[Email protected] ~]# cd/home/user/downloads

[Email protected] ~]# TAR-ZXVF mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz

Move files to the specified directory

[Email protected] ~]# MV mysql-5.7.10-linux-glibc2.5-x86_64/home/mysql/mysql-5.7.10

Third, install the package required to run MySQL

[email protected] ~]# Yum search Libaio

[email protected] ~]# Yum install Libaio

Iv. Installing and configuring MySQL

Refer to the install-binary in MySQL file;

[Email protected] ~]# groupadd MySQL #添加一个mysql用户组

[[email protected] ~]# useradd-r-G mysql-s/bin/false MySQL #设置-s/bin/false means that MySQL cannot be logged in as a user

[ email protected] ~]# cd/usr/local [[email protected] ~]# ln-s/home/mysql/mysql-5.7.10 MySQL Create a MySQL link #在 the/usr/local/directory

[[Email protected] ~]# CD mysql [[email protected] ~]# mkdir data #作为存放数据的目录

[Email protected] ~]# chmod 770 Data #修改data目录的进入权限

[Email protected] ~]# chown-r mysql:mysql. #修改当前文件夹的用户权限和组权限

[Email protected] ~]# bin/mysqld--initialize--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/ Data # MySQL 5.7.10 initialization settings

After executing the command, note the last line of the [note] Information

[Note] A temporary password is generated for [email protected]: 9AsdF (the initial password generated by the +86h49 is used for the first time when the root user is logged in;

[Email protected] ~]# bin/mysql_ssl_rsa_setup--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data # mysql 5.7.10 Secure connection Settings

[Email protected] ~]# chown-r root.
[[email protected] ~]# chown-r mysql data
[Email protected] ~]# Cd/var/log
[Email protected] ~]# mkdir MySQL #作为存放数据库运行日志的文件夹

[Email protected] ~]# cd/usr/local/mysql/

[email protected] ~]# Bin/mysqld_safe--user=mysql--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data & #此命令在后台运行

Add MySQL to the folder that controls the startup service and name MySQL, which is the service-controlled name, at which time you can start and shut down MySQL with service MySQL start|stop control

[email protected] ~]# CP Support-files/mysql.server/etc/init.d/mysql

Service MySQL start is available to start the MySQL database.
Configure boot-up MySQL service

[[email protected] ~]# chkconfig--add MySQL
[[email protected] ~]# chkconfig--level 2345 MySQL on

Five, first login MySQL
[Email protected] ~]# mysql-u root-p
Enter Password: Enter the temporary password generated before mysql> SET password = password (' 123456 '); #注意最后的分号;

Vi. Other Configurations

A) Open the firewall MySQL 3306 port external access after CentOS upgrade to 7, use FIREWALLD instead of the original iptables.

Below is a note on how to open Linux ports using FIREWALLD

--zone: Scope, the network region defines the trusted level of the network connection. This is a one-to-many relationship, which means that a connection can only be part of a region, and a region can be used for many connections

--add-port: Add port and communication protocol in the format: Port/Communication Protocol, protocol TCP or UDP

--permanent: Permanent, without this parameter the port access fails after the system restarts

[Email protected] ~]# firewall-cmd--zone=public--add-port=3306/tcp--permanent

[Email protected] ~]# firewall-cmd--reload #重启防火墙

b) Five MySQL grant examples (MySQL users, non-centos users)

example One, allow the user name root password 123456 from any host to connect to the MySQL server, the root account that was created is only an external access account, unlike the internal Linux root account used to access the MySQL, and internal Linux access to the MySQL root is not the Linux system root account

Mysql>grant all privileges on * * to ' root ' @ '% ' identified by ' 123456 ' with GRANT OPTION;

example two, to the user from the 192.168.155.1 user1 assigned to the Database dbname tablename table Select,insert,update,delete,create,drop and other operations permissions, and set the password to 123456. There are a lot of permissions to table operations like alter and so on

Mysql>grant Select,insert,update,delete,create,drop on Dbname.tablename to ' user1 ' @ ' 192.168.155.1 ' identified by ' 123456 ';

Mysql>grant Select,insert,update,delete,create,drop on Dbname.tablename to ' user1 ' @ ' 192.168.155.1 ' identified by ' 123456 ';

Example three, to the user from the 192.168.155.1 user2 assigned to the database dbname all the tables to do all the permissions, and set a password of 123456.

Mysql>grant all privileges in dbname.* to ' user2 ' @ ' 192.168.155.1 ' identified by ' 123456 ';

Example four, to the user from the 192.168.155.1 User3 assigned to all the tables all the database permissions, and set a password of 123456.

Mysql>grant all privileges on * * to ' user3 ' @ ' 192.168.155.1 ' identified by ' 123456 ';

Example one, to the native user User4 assign permissions to all the tables in all databases, and set the password to 123456.

Mysql>grant all privileges on * * to ' user4 ' @ ' localhost ' identified by ' 123456 ';

Example five, refresh permissions;

Mysql>flush privileges;

c) Reference:

1. install-binary file in MySQL installation file

2, http://www.cnblogs.com/dreamhome/p/4716425.html;

3. Linux Configuration Firewall Open 3306 port

4, CentOS7 Firewall firewall detailed

I also beginner MySQL, Caishuxueqian, there must be a bad place to say, I hope you have a lot of advice, I will promptly correct, but please do not add words! Thank you.

If you like this article, please leave a message at the back.

CentOS installation MySQL Guide

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.