当前位置:首页 > 建站学院 > 服务器 >  Centos 安装mysql

Centos 安装mysql

服务器   发布日期:2025年06月14日   浏览次数:154

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:
    1. 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:
    1. 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
  1. shell> yum repolist all | grep mysql
  2. 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):
  1. shell> sudo yum install mysql-community-server
  1. Starting the MySQL Server
    Start the MySQL server with the following command:
  1. 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:

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

change validate_password

  1. set global validate_password.policy=0;

Allow external access

  1. use mysql
  2. update user set host='%' where user='root';
  1. alter user 'root'@'localhost' identified with mysql_native_password by '123456';

以上就是Centos 安装mysql的详细内容,更多关于Centos 安装mysql的资料请关注九品源码其它相关文章!