preface

MySQL > MySQL > MySQL > MySQL > MySQL > MySQL > MySQL > MySQL > MySQL > MySQL > MySQL

Because small make up before using Docker MySQL installation, the server goes down, suddenly one day when I restart the whole set of services, I found my database all gone, ok not happened in the company’s production project, I spent a lot of trouble to get all the database back, so suggest everybody in the company, these important services such as database, Best honest step by step installation, even if the error, a document search is, a lot of, do not engage in those bells and bells, what should be used? How does it work? How to use? It’s all about choice.

1. Installation steps

1. Check whether the MySQL is installed

rpm -qa|grep mariadb
Copy the code
rpm -qa|grep mysql
Copy the code

If nothing is displayed, the operating system is clean and new MySQL can be installed.

2. Check the operating system version

cat /etc/redhat-release
Copy the code

Download and install MySQL official Yum Repository

wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
Copy the code

4. Install the REPo

When the installation is complete, two files will be produced in this directory:

cd /etc/yum.repos.d/
Copy the code

Install the MySQL Server

yum install mysql-server
Copy the code

If the following information is displayed, the installation is successful.

6. Start MySQL

systemctl start mysqld.service 
Copy the code

MySQL > Check the running status of MySQL.

systemctl status mysqld.service
Copy the code

Check the mysql process:

ps -ef|grep mysqld
Copy the code

7. Enter the MySQL terminal

mysql -uroo -p
Copy the code

After the first successful installation, you can enter the terminal without entering the password.

At this point we set the password.

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
Copy the code

At this point we log out again and log in to MySQL again.

At this point, the password takes effect.

Enter the correct password. Enter after the successful login !!!!!!!!!!!!!!!!!!

8. Set the remote connection

1. Enable the firewall

Check the firewall status systemctl Status firewalld Enable the firewall systemctl start firewalld Disable the firewall systemctl stop firewalldCopy the code

2. Open port 3306

Add the specified port to open: firewall-cmd --zone=public --add-port=3306/ TCP --permanent Reloads the added port: firewall-cmd --reload To query whether the specified port is enabled: firewall-cmd --query-port=3306/tcp
Copy the code

After the above Settings are successful, use Navcate connection, or report an error, authorization problem.

2. Remote connection authorization

Enter the MySQL terminal and run the following commands.

After entering the database, use the mysql database

use mysql;
Copy the code

Viewing the user table

select 'Host'.'User' from user;
Copy the code

Update user root; % indicates that any IP address can be used to log in

UPDATE user SET Host= The '%' WHERE User= 'root' LIMIT 1;
Copy the code

Force Refresh Permission

flush privileges;
Copy the code

Connect again. The connection succeeds.

conclusion

Above is today to talk about the content, stay up late dry goods, creation is not easy, like please pay attention to !!!!!!!!!!!!!!!!