linux安装mysql常出现的问题

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

yum update

yum install mysql-server

权限设置:

chown -R mysql:mysql /var/lib/mysql/

初始化 MySQL:

mysqld --initialize

查看 MySQL 运行状态:systemctl status mysqld

启动mysql服务 重要:systemctl start mysqld

启动mysql服务报错

Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)

Active: failed (Result: exit-code) since Wed 2025-04-09 19:05:37 CST; 3min 23s ago

Process: 324472 ExecStopPost=/usr/libexec/mysql-wait-stop (code=exited, status=0/SUCCESS)

Process: 324444 ExecStart=/usr/libexec/mysqld --basedir=/usr (code=exited, status=1/FAILURE)

Process: 324354 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)

Process: 324303 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)

Main PID: 324444 (code=exited, status=1/FAILURE)

Status: "Server startup in progress"

Error: 2 (没有那个文件或目录)

解决办法:

chmod -R 777 /var/lib/mysql

使用以下命令来创建root用户的密码

mysqladmin -u root password "123456";

mysql -u root -p

密码相关问题

vim /etc/my.cnf

mysqld

skip-grant-tables #添加此行,跳过密码验证,忽略权限表身份验证

重启

systemctl restart mysqld

直接进入mysql

mysql

show databases;

describe mysql.user;

select host,user,authentication_string from mysql.user;

更改密码

update mysql.user set authentication_string=password('123456') where user='root';

在 MySQL 5.7 及更高版本中,使用以下命令更新密码:

sql

复制

复制代码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

刷新授权

flush privileges;

quit

注释掉跳过密码

vim /etc/my.cnf

再次重启 MySQL 服务

bash

复制代码
systemctl restart mysqld

登录mysql

mysql -uroot -p123456

相关推荐
码路飞1 小时前
写了个 AI 聊天页面,被 5 种流式格式折腾了一整天 😭
javascript·python
曲幽3 小时前
FastAPI压力测试实战:Locust模拟真实用户并发及优化建议
python·fastapi·web·locust·asyncio·test·uvicorn·workers
chlk1237 小时前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑7 小时前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件8 小时前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
敏编程8 小时前
一天一个Python库:jsonschema - JSON 数据验证利器
python
前端付豪8 小时前
LangChain记忆:通过Memory记住上次的对话细节
人工智能·python·langchain
碳基沙盒8 小时前
OpenClaw 多 Agent 配置实战指南
运维
databook8 小时前
ManimCE v0.20.1 发布:LaTeX 渲染修复与动画稳定性提升
python·动效
深紫色的三北六号17 小时前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移