MySql detailed tutorial under Linux (Centos7.6) Installation

The database used more specific nagging not directly mounted on the base operation mysql:

 

1, check whether the Linux installation mariadb database, mariadb mysql database is a branch of

Excuting an order:
yum list installed | grep mariadb 

 

2, if Linux is installed in the mariadb database, uninstall first, because CentOS 7.6 integrates a mariadb, and then install mysql and will file conflicts mariadb, so you need to uninstall mariadb

Excuting an order:
yum -y remove mariadb-libs.x86_64

 

3, start the installation mysql, mysql first download the software compression package from the official website and upload it to the Linux opt / mysoft directory

Mysql extract the downloaded software compression package, execute the command:
tar -zxvf /opt/mysoft/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local

 

4, will be renamed after extracting mysql-5.7.24-linux-glibc2.12-x86_64 to mysql-5.7.24 or mysql, this depends on personal habits, and unnecessary operations

Excuting an order:
mv mysql-5.7.24-linux-glibc2.12-x86_64 mysql-5.7.24

 

5, created in the mysql-5.7.24 folder directory / data / 3306 folder, this is also a matter of personal habit, and non-essential operations

Switch to 5.7-MySQL .24 directory, execute the command:
mkdir -vp ./data/3306 (v represents the creation of new directories are displayed information, p represents the recursive creation)

 

6, add a mysql user and group

Excuting an order:
groupadd mysql
MySQL useradd -g MySQL (-g: Specifies the user is set)

 

7, switch to the mysql-5.7.24 / bin directory execute:

./mysqld --initialize-insecure --user=mysql --datadir=/usr/local/mysql-5.7.24/data/3306 --basedir=/usr/local/mysql-5.7.24--initialize-insecure标识不设置密码, root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.)

 

8, in the mysql-5.7.24 / bin directory

Excuting an order:
. / Mysql_ssl_rsa_setup --datadir = / usr / local / MySQL 5.7.24-/ Data / 3306 (access of a secure connection, generates an RSA private key)

 

9, change mysql-5.7.24 entire folder directory permissions belongs

Excuting an order:
chown -R & lt MySQL: MySQL /usr/local/mysql-5.7.24 (- R & lt recursive iteration represented)
chmod: file / directory permissions command

 

1 0 create a my.cnf file in the mysql-5.7.24 / data / 3306 directory

Use the command: vim my.cnf
[client]
port = 3306
socket = /usr/local/mysql-5.7.24/data/3306/mysql.sock
default-character-set=utf8

[mysqld]
port = 3306
socket = /usr/local/mysql-5.7.24/data/3306/mysql.sock
datadir = /usr/local/mysql-5.7.24/data/3306
log-error = /usr/local/mysql-5.7.24/data/3306/error.log
pid-file = /usr/local/mysql-5.7.24/data/3306/mysql.pid

character-set-server =utf8
# Whether to ignore case, lower_case_table_names the unix default value 0 .Windows default value is 1 (case-insensitive comparison name) .Mac OS X default value is 2 .
lower_case_table_names = 1
# 0 indicates whether to automatically submit not automatically submit 1 means the automatic submission, mysql transaction support engine is InnoDB, in the case of default autocommit value of 1
autocommit = 1

 

At this point MySQL installation is complete;

 

11, start the MySQL service

In the mysql-5.7.24 / command in the bin directory:
. / File---defaults the mysqld_safe = / usr / local / MySQL 5.7.24-/ Data / 3306 / the my.cnf & (wherein the symbol represents & backgrounding)

 

12, change passwords

Log into mysql, the mysql-5.7.24 / command in the bin directory:
./mysql -uroot -p -P3306 -h127.0.0.1
Modify the mysql password, execute:
alter user 'root'@'localhost' identified by '123456';

13, unauthorized remote access

a, After logging in, execute the command :( so that remote clients can access)
grant all privileges on *.* to root@'%' identified by '123456';
Where * * * represents all first database name, * second means all database tables;
@ root '%' in the root represents the user name, address means ip%,% can also specify a particular ip address, such as root @ localhost, root @ 192.168.10.888

b, if not remote access, execute the following command to refresh the following rights:
flush privileges; 

c, if after the implementation of the above authorized remote access remote connection is still not on the mysql, may be blocked by the firewall on Linux

d, open firewall port command:
firewall-cmd --zone=public --add-port=3306/tcp --permanent
Command Meaning:
--zone # Scope: View current locale: Firewall-cmd --get- default - Zone
 --add-Port = 3306 / tcp # Add port, the format is: port / protocol
 - Permanent # permanent, no this parameter is invalid after the restart

Reload the firewall configuration: Firewall -cmd - reload

Restart the firewall: systemctl restart firewalld

Cancel ports open:
firewall-cmd --zone=public --remove-port=3306/tcp --permanent

Query port number 8080 is turned on:
firewall-cmd --query-port=8080/tcp

Discover what ports are open:
firewall-cmd --list-port

 

14, shut down MySQL service

Enter mysql-5.7.24 / command in the bin directory:
./mysqladmin -uroot -p -P3306 -h127.0.0.1 shutdown

 

15, other commands

mysql 5.5, mysql 5.6, mysql 5.7 : default maximum number of connections are 151, upper limit: 100,000 th;
mysql5.0 version: The default maximum number of connections is 100, the upper limit is 16384;

Check the maximum number of connections mysql:
show variables like '%max_connections%';

View the current number of connections:
show global status like 'max_used_connections';

 

Write blog is easy to forget in order to remember what they are, but also for their additional work summary, the article may be reproduced without copyright. We want to make their own efforts to do better, we work together to progress! If you have any questions, please discuss with everyone, the code any questions, welcome to correct me great God!

Guess you like

Origin www.cnblogs.com/summary-2017/p/12116187.html