centos Mysql8.0 环境安装及远程登录配置

本文档详细介绍了在CentOS8上使用yum安装MySQL8.0服务器的过程,包括启动、设置临时密码、修改root密码以及创建允许远程登录的用户。还涉及到配置文件的修改以允许远程连接,并提供了相关命令的执行示例。
摘要由CSDN通过智能技术生成
  • yum search mysql
  • yum info mysql-server.x86_64
[root@VM-16-2-centos ~]# yum info mysql-server.x86_64
Last metadata expiration check: 1:50:01 ago on Wed 25 Aug 2021 11:30:34 AM CST.
Installed Packages
Name         : mysql-server
Version      : 8.0.21
Release      : 1.module_el8.2.0+493+63b41e36
Architecture : x86_64
Size         : 108 M
Source       : mysql-8.0.21-1.module_el8.2.0+493+63b41e36.src.rpm
Repository   : @System
From repo    : appstream
Summary      : The MySQL server and related files
URL          : http://www.mysql.com
License      : GPLv2 with exceptions and LGPLv2 and BSD
Description  : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
             : client/server implementation consisting of a server daemon (mysqld)
             : and many different client programs and libraries. This package contains
             : the MySQL server and some accompanying files and directories.
  • yum install mysql-server.x86_64 -y
  • 使用mysqld启动,会有临时密码
$ mysqld --initialize --user=mysql
$ mysql_ssl_rsa_setup
$ mysqld --user=mysql &
# 查找日志位置
$ find / -name mysqld.log
# 查找root临时密码
$ grep 'temporary password' /var/log/mysql/mysqld.log
2021-08-25T05:23:38.193390Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: aMf?3;gE3Iom
  • systemctl start mysqld
  • root登录及修改密码
# 登录,无密码,直接回车
$ mysql -uroot -p 
# 修改密码
> ALTER user 'root'@'localhost' IDENTIFIED BY 'root123456'
  • 创建账号允许远程登录
# 允许所有ip连接
> create user 'work'@'%' identified by 'work123456';
> grant all on *.* to work@'%';
> flush privileges;
# 设置mysql允许远程连接
$ vim /etc/my.cnf.d/mysql-server.cnf 
# 添加下面这一行允许远端ip连接服务器
bind-address = 0.0.0.0
# 重启mysql服务
systemctl restart mysqld
参考 https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值