MySQL installation (detailed)


foreword

insert image description here

  This tutorial is a detailed explanation of installing mysql under Linux. There are two ways for you to choose, and the personal test is effective.


One, yum way to install

1. Download and install MySQL

wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm &&
yum -y install mysql57-community-release-el7-10.noarch.rpm &&
yum -y install mysql-community-server

2. Start the MySQL database

systemctl start mysqld.service

3. View the initial MySQL password

grep "password" /var/log/mysqld.log

4. Login to the database

mysql -uroot -p

5. Modify the MySQL default password

set global validate_password_policy=0;
#修改密码安全策略为低(只校验密码长度,至少8位)。
ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';

6. Grant the root user remote management privileges

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345678';

7. Enter exit to exit the database

exit;

Two, rpm installation method

1. Check

1. Check all installed software

rpm -qa        

2. Check the installed mysql

rpm -qa | grep mysql		

3. Check the installed mariadb (CentOS is installed by default, which conflicts with mysql installation)

				rpm -qa | grep mariadb     

2. Uninstall mariadb

		rpm -e --nodeps  mariadb     

3. Installation

1. Create a folder

mkdir  /usr/local/mysql

2. Upload the installation file and move it to the mysql folder

mv mysql-5.7.25-1.el7.x86_64.rpm-bundle.tar.gz /usr/local/mysql

3. Unzip

tar -zxvf mysql xxxxxx

4. Installation

  rpm -ivh ******      -->按顺序

insert image description here

4. Start

1. Open mysql

systemctl start mysqld

2. Check whether it is started

systemctl status mysqld

3. Boot up automatically

systemctl enable mysqld

4. View the enabled services

netstat -tunlp 
netstat  -tunlp  | grep mysql   

5. Check the process

ps -ef | grep mysql 

5. Password

1. View the temporary password:

cat /var/log/mysqld.log  | grep password  

2. Set password security level

set global validate_password_length=3;

​set global validate_password_policy=LOW;

3. Change password

set password for root@localhost = password('123');

6. Navicat connection
1. Open access rights

grant all on *.* to 'root'@'%' identified by 'root' 

2. Refresh permissions

flush privileges;  

3. Use Navicat to connect to
eg: enter the IP, port number, and user password to connect

insert image description here

Summarize

   The above is the whole content of MySQL installation, I hope it will be helpful to you.

Guess you like

Origin blog.csdn.net/qq_53463544/article/details/129152468