【无标题】

Linux Yum安装MySQL

yum安装MySQL

  1. 下载yum源

    # 下载地址 https://dev.mysql.com/downloads/repo/yum
    
    # 此处以下方文件为例:该文件下载地址: https://dev.mysql.com/get/mysql80-community-release-el8-4.noarch.rpm
    wget mysql80-community-release-el8-4.noarch.rpm
    
  2. 安装rpm

    # 安装下载的文件
    yum install -y mysql80-community-release-el8-4.noarch.rpm
    # 上诉出现 Nothing to do!, 则已经安装或者未卸载干净
    yum clean all
    yum makecache
    
  3. 安装MySQL

    # 安装MySQL
    yum install -y mysql-community-server
    

    若提示一下内容,则执行:yum module disable mysql

    MySQL 8.0 Community Server                                                                                                                  396 kB/s | 2.6 kB     00:00    
    MySQL Connectors Community                                                                                                                  411 kB/s | 2.6 kB     00:00    
    MySQL Tools Community                                                                                                                       428 kB/s | 2.6 kB     00:00    
    All matches were filtered out by modular filtering for argument: mysql-community-server
    Error: Unable to find a match: mysql-community-server
    
  4. MySQL操作命令

    # 查看状态
    systemctl status mysqld
    # 启动
    systemctl start mysqld
    # 停止
    systemctl stop mysqld
    # 开机启动
    
  5. 修改密码、远程连接

# 修改密码
1. 查看默认密码
grep 'temporary password' /var/log/mysqld.log

2022-08-25T16:51:47.483033Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ITFeX#M45scx

如果没有默认密码,则在/etc/my.cnf中的[mysqld]下添加skip-grant-tables
# 登录mysql
mysql -uroot -p"ITFeX#M45scx" # 如果添加了skip-grant-tables,则密码随便填
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root@rooT@123';

# 远程连接
CREATE USER 'root'@'%' IDENTIFIED BY '密码';
GRANT ALL ON *.*  TO 'root'@'%';
# 刷新
flush privileges
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值