惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 挥辉

评估vosk模型的词错率,响应时间和吞吐量 在 macOS 中遇到 brew 命令不存在的问题 comfyui on Mac M4 【转】向量数据库与Milvus Mac下使用Windows键盘的主要按键对应设置 MacOS安装软件及运行时,提示“已损坏无法打开”的解决方案 MAXKey SSO Docker Compose部署 【AI落地验证-1】Dify本地搭建 【AI落地验证-1】CentOS Docker 安装 【转载】APM——SkyWalking 是什么 [转载]9个顶级开发IoT项目的开源物联网平台 转——visual studio快捷键大全 等保测评:你们要的漏扫工具来了(附工具下载链接) 转-计算文件哈希值 转-python安装openCV介绍 转-python依赖包整体迁移方法 转-Mongodb亿级数据量的性能测试 转-MongoDB的真正性能-实战百万用户 转-Python操作MongoDB看这一篇就够了
[转]Install MySQL CentOS
挥辉 · 2025-08-22 · via 博客园 - 挥辉

Summary: in this tutorial, you will learn step-by-step how to install MySQL 8 on CentOS 7.

To install MySQL 8 on CentOS 7, you follow these steps:

Step 1. Add the MySQL Yum Repository

Add the official MySQL repository to your system’s package manager (yum)

sudo rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm

Code language: JavaScript (javascript)

Step 2. Download the official MySQL GPG key using

sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql

Code language: JavaScript (javascript)

Step 3. Install MySQL 8 Community Server

Install the MySQL 8 Community Server package using the following command:

sudo yum install mysql-server

Step 4. Start MySQL Service

Start the MySQL service and enable it to run at boot with:

sudo systemctl start mysqld
sudo systemctl enable mysqld

Step 5. Show the default password for the root user

When you install MySQL 8.0, the root user account is granted a temporary password. To show the password of the root user account, you use the following command:

sudo grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}'

Code language: JavaScript (javascript)

Here is the output:

Kq%<ul_0M*O0

Note that your temporary password will be different. You will need this password to change the password of the root user account.

Step 6. MySQL Secure Installation

Execute the command mysql_secure_installation to secure the MySQL server:

mysql_secure_installation

It will prompt you for the current password of the root account:

Enter password for user root:

Enter the temporary password above and press Enter. The following message will show:

The existing password for the user account root has expired. Please set a new password.

New password:
Re-enter new password:

Code language: PHP (php)

You will need to enter the new password for the root‘s account twice. It will prompt some questions, it is recommended to type yes (y):

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

Step 7. Connect to MySQL

Use this command to connect to the MySQL server:

mysql -u root -p

It will prompt you for the password of the root user. You type the password and press Enter:

Enter password:

It will show the mysql command:

mysql>

Use the SHOW DATABASES to display all databases in the current server:

mysql> show databases;

Code language: SQL (Structured Query Language) (sql)

Here is the output:

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.05 sec)

Code language: JavaScript (javascript)

In this tutorial, you have learned step-by-step how to install MySQL 8 on CentOS 7.

MySQL Root账号远程访问配置指南

本文将指导您如何安全地配置MySQL root账号以允许远程访问,并提供最佳实践建议。

配置步骤

1. 修改MySQL配置

首先需要确保MySQL服务监听所有网络接口,而不仅仅是本地回环地址。

编辑MySQL配置文件(通常位于/etc/mysql/my.cnf/etc/mysql/mysql.conf.d/mysqld.cnf):

[mysqld]
bind-address = 0.0.0.0  # 改为监听所有网络接口

2. 创建或修改MySQL用户权限

登录MySQL并执行以下命令:

3. 重启MySQL服务

sudo systemctl restart mysql

4. 配置防火墙(如果需要)

如果服务器启用了防火墙,需要开放MySQL端口(默认3306):

安全注意事项

<div class="warning"> <strong>安全警告:</strong>允许root账号远程访问会带来安全风险,请考虑以下建议 </div>

  1. 使用强密码:确保root密码足够复杂

  2. 限制访问源IP:只允许特定IP地址访问

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.%' WITH GRANT OPTION;
  3. 考虑使用SSH隧道:替代直接远程连接

  4. 定期审查访问日志:监控异常连接尝试

  5. 使用非标准端口:考虑更改MySQL默认端口

连接测试

使用以下命令测试远程连接:

mysql -h [服务器IP] -u root -p

替代方案(推荐)

考虑创建具有必要权限的专用用户,而非直接使用root账号:

CREATE USER 'admin'@'%' IDENTIFIED BY 'strong_password';
GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'admin'@'%';

总结

允许MySQL root账号远程访问应谨慎实施。务必采取适当的安全措施,并考虑使用专用管理账户而非root账户进行远程管理。

记得在完成配置后验证设置是否正确,并测试连接是否正常工作。