CentOS7 installation Mysql8

Source: Internet
Author: User
Tags mysql version iptables pscp yum repolist

This article mainly from the following aspects of their own under the CENTOS7 installation Mysql8 process to do the following summary:

    • CENTOS7 installation Mysql8 step;
    • Window under the Navicat connection MySql8;
    • The Linux commands involved

80039650

--------------------------------------------------------------------------------------------------------------- ---

The first part CentOS7 installation mysql1.1 The pre-installation cleaning work; 1.1.1 Clean up the original MySQL database;

Use the following command to find out the installed MySQL package and the dependent package:

rpm -pa | grep mysql

The results appear as follows:

    1. Mysql80-community-release-el7-1.noarch
    2. Mysql-community-server-8.0.11-1.el7.x86_64
    3. Mysql-community-common-8.0.11-1.el7.x86_64
    4. Mysql-community-libs-8.0.11-1.el7.x86_64
    5. Mysql-community-client-8.0.11-1.el7.x86_64

Use the following command to delete the above program in turn

yum remove mysql-xxx-xxx-

Delete the MySQL configuration file, uninstall does not automatically delete the configuration file, first use the following command to find out the use of the configuration file;

find / -name mysql

The possible display results are as follows:

    1. /etc/logrotate.d/mysql
    2. /etc/selinux/targeted/active/modules/100/mysql
    3. /etc/selinux/targeted/tmp/modules/100/mysql
    4. /var/lib/mysql
    5. /var/lib/mysql/mysql
    6. /usr/bin/mysql
    7. /usr/lib64/mysql
    8. /usr/local/mysql

Use the following command to delete the configuration file in turn, as required

rm -rf /var/lib/mysql
1.1.2 Delete mariadb files,

Since MySQL is charged in CentOS7, MySQL has not been supported, instead of CentOS7 internal integration of MARIADB, and the installation of MySQL will conflict with mariadb files, so you need to uninstall the MARIADB first.

Use the RPM command to find out the mariadb file to be deleted;

rpm -pa | grep mariadb

The possible display results are as follows:

mariadb-libs-5.5.56-2.el7.x86_64

Remove the above program

rpm -e mariadb-libs-5.5.56-2.el7.x86_64

You may see the following error message:

    1. Dependency detection failure:
    2. libmysqlclient.so.18 () (64bit) was (installed) postfix-2:2.10.1-6.el7.x86_64 required
    3. libmysqlclient.so.18 (libmysqlclient_18) (64bit) was (installed) postfix-2:2.10.1-6.el7.x86_64 needed
    4. libmysqlclient.so.18 (libmysqlclient_18) (64bit) was (installed) postfix-2:2.10.1-6.el7.x86_64 needed

Use force Delete:

rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

At this point, the original MySQL and mariadb database deleted;

1.2 Installing mysql1.2.1 MySQL repo source available under MySQL website

CentOS's Yum source is not MySQL by default, so we need to go to the official website to download MySQL repo source and install it;

MySQL website download link: MySQL repo as follows:

1.2.2 uploading files to CentOS using Putty's PSCP

Use putty to upload the F: Disk just under the good MySQL repo file to the Centos/usr/local/mysql folder;

D:\Putty>pscp F:\mysql80-community-release-el7-1.noarch.rpm [email protected]:/usr/local/mysql/
1.2.3 Install the Yum repo file and update the Yum cache;
rpm -ivh mysql57-community-release-el7-11.noarch.rpm

Execution Result:

Two repo files are generated under the/etc/yum.repos.d/directory Mysql-community.repo Mysql-community-source.repo

Update Yum command

    1. Yum Clean All
    2. Yum Makecache
1.2.4 Installing MySQL with yum

When we install MySQL with yum, Yum installs MySQL's newest GA version from the Yum repository by default, and how to choose its own version;

Step one: View the MySQL version in the MySQL Yum repository using the following command

yum repolist all | grep mysql

You can see that MySQL 5.5 5.6 5.7 is disabled and MySQL 8.0 is enabled;

The second step uses the Yum-config-manager command to modify the appropriate version to enable the latest version to disable the state

    1. Yum-config-manager--disable mysql80-community
    2. Yum-config-manager--enable mysql57-community

Or you can edit the MySQL repo file,

Change the corresponding version of enabled to 1;

1.2.5 Install the MySQL command as follows:
yum install mysql-community-server

1.2.6 turn on MySQL service
systemctl start mysqld.service
1.2.7 Get initial password login MySQL

MySQL will create an [email protected] account after installation, and put the initial password in the/var/log/mysqld.log file;

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

Log in to MySQL with the initial password

Modify the initial password: So the password you just started must match the length and must contain numbers, lowercase or uppercase letters, special characters.

ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘MyNewPass4!‘;
1.2.8 Open Port 3306 in the firewall

CentOS7 default is to use firewall as a firewall, I changed here to become accustomed to the common iptables firewall

First step: Turn off firewall firewall

    1. Systemctl Stop Firewalld.service
    2. Systemctl Disable Firewalld.service
    3. Systemctl Mask Firewalld.service

Step Two: Install the iptables firewall

yum install iptables-services -y

Step three: Start iptable firewall

    1. Systemctl Enable Iptables
    2. Systemctl start iptables

Fourth Step: Edit Firewall Add port Firewall file location:/etc/sysconfig/iptables

vim /etc/sysconfig/iptables

Add on the third line to the bottom

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

Fifth Step: Restart the firewall

    1. Systemctl Enable Iptables.service
    2. Systemctl Start Iptables.service
1.2.9 Add the MySQL service to the boot entry and start the MySQL process
    1. Systemctl Enable Mysqld.service
    2. Systemctl Start Mysqld.service

Common MySQL service commands:

    1. Log in to MySQL
    2. Mysql-u username-p
    3. Quit MySQL
    4. Quit
    5. Start MySQL
    6. Systemctl Start Mysqld.service
    7. End
    8. Systemctl Stop Mysqld.service
    9. Restart
    10. Systemctl Restart Mysqld.service
    11. Power-on self-booting
    12. Systemctl Enable Mysqld.service
    13. View MySQL version
    14. Select version ();

This section references the documentation:

Reference 1:centos Installing MySQL

Literature 2:a Quick Guide to Using the MySQL Yum Repository

--------------------------------------------------------------------------------------------------------------- ---

Part Two Navicat connection Mysql82.1 turn on MySQL remote service: 2.1.1 Modify the value of host in the user table under MySQL database

It may be that your account is not allowed to log on remotely, only on localhost. This time, as long as the computer on the localhost, log in to MySQL, change the "MySQL" Database in the "User" table "host" entry, from "localhost" to "%" log into the MySQL database to execute the following command:

    1. Mysql-u root-p
    2. Use MySQL;
    3. Update user set host= '% ' where user= ' root ';

2.1.2 How to use authorization

Give any host access to data

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES

If you want to myuser users to use the MyPassword password from any host to connect to the MySQL server.

GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘%‘IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;

If you want to allow users to connect to the MySQL server from a host myuser IP 192.168.1.6 and use MyPassword as the password

GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘192.168.1.3‘IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;
2.2 The following error is reported when using Navicat for MySQL to connect MySQL 8.0:

mysql8.0 introduces a new feature Caching_sha2_password; This encryption method is not supported by the client, and the client supports Mysql_native_password.

We can view the plugin field of the user table in the MySQL database;

You can use the command to change him to Mysql_native_password encryption mode:

update user set plugin=‘mysql_native_password‘ where user=‘root‘;

Then use Navicat link can link success;

This section refers to the following articles:

Reference 1:mysql two ways to open a remote

Reference 2: Initial installation of MySQL encountered problems

--------------------------------------------------------------------------------------------------------------- ---

The third part: The Linux command learning involved in the installation process;

3.1 rpm

3.2 Putty upload file PSCP command;

On the window machine CD into the Pttty installation directory:

    cd :\program files (x86)\Putty

Copy local files to Linux : PSCP file User name @linuxip: directory

    pscp hello.txt [email protected]:/tmp/userfile/

Copy the local folder to Linux:pscp-r directory user name @linuxip: directory

   pscp -r c:\file [email protected]:/root/testFolder  

Copy the file \root\test.txt on Linux to the local C-drive src folder as follows:

   pscp [email protected]_pc:/root/test.txt  C:\src  

3.3 Modifying Firewall files/etc/sysconfig/iptables

3.4 systemctl Command

CentOS7 installation Mysql8

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.