Centos 安装mysql

1.Adding the MySQL Yum Repository

First, add the MySQL Yum repository to your system's repository list. Follow these steps:

  • Go to the download page for MySQL Yum repository at http://dev.mysql.com/downloads/repo/yum/.
  • Select and download the release package for your platform.
  • Install the downloaded release package with the following command, replacing platform-and-version-specific-package-name with the name of the downloaded package:
    shell> sudo rpm -Uvh platform-and-version-specific-package-name.rpm
    
    For example, for version n of the package for EL6-based systems, the command is:
    shell> sudo rpm -Uvh mysql80-community-release-el6-n.noarch.rpm
    

    Note
    Once the release package is installed on your system, any system-wide update by the yum update command (or dnf upgrade for dnf-enabled systems) will automatically upgrade MySQL packages on your system and also replace any native third-party packages, if Yum finds replacements for them in the MySQL Yum repository. See Upgrading MySQL with the MySQL Yum Repository and Replacing a Native Third-Party Distribution of MySQL for details.

  1. Selecting a Release Series
shell> yum repolist all | grep mysql
shell> yum repolist enabled | grep mysql
  1. Installing MySQL
    Install MySQL by the following command (for dnf-enabled systems, replace yum in the command with dnf):
shell> sudo yum install mysql-community-server
  1. Starting the MySQL Server
    Start the MySQL server with the following command:
systemctl start mysqld.service

A superuser account 'root'@'localhost' is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:

shell> sudo grep 'temporary password' /var/log/mysqld.log
  1. setting

change validate_password

set global validate_password.policy=0;

Allow external access

use mysql
update user set host='%' where user='root';
alter user 'root'@'localhost' identified with mysql_native_password by '123456';
原文地址:https://www.cnblogs.com/tongchengbin/p/9354904.html