CentOS7安装MySQL服务
CentOS7安装MySQL服务
1、安装wget
yum install wget
2、mysql下载
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
3、安装软件源
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
4、 安装mysql服务端
yum install -y mysql-community-server
5、启动mysql
service mysqld start
- 如果在启动服务时失败,报如下错误
Job for mysqld.service failed because the control process exited with error code. See “systemctl status mysqld.service” and “journalctl -xe” for details.
参见另一篇文章 虚拟机启动mysql服务遇到的问题
6、检查mysql运行状态
service mysqld status
[root@test-zj ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-04-22 07:15:23 UTC; 37s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 2141 (mysqld)
CGroup: /system.slice/mysqld.service
└─2141 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Apr 22 07:15:08 test-zj systemd[1]: Starting MySQL Server...
Apr 22 07:15:23 test-zj systemd[1]: Started MySQL Server.
7、查看临时密码
grep 'temporary password' /var/log/mysqld.log
[root@test-zj ~]# grep 'temporary password' /var/log/mysqld.log
2020-04-22T07:15:19.556900Z 1 [Note] A temporary password is generated for root@localhost: u1J1-TkhsUX<
8、输入临时密码,进行登录
mysql -u root -p
[root@test-zj ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
9、修改validate_password_policy参数的值
set global validate_password_policy=0;
10、修改密码的长度
set global validate_password_length=1;
11、修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
如果不执行9和10,直接修改密码,会报如下错误 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
转载文档
https://juejin.im/post/5def2a82518825126e6396be
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· Vue3状态管理终极指南:Pinia保姆级教程