centos8 yum 安装mysql8.0

centos8 yum 安装mysql8.0

半寸时光丶关注

2021.03.28 16:02:38字数 195阅读 110

安装mysql

获取官方下载地址 https://dev.mysql.com/downloads/repo/yum/

centos8 yum 安装mysql8.0

centos8 yum 安装mysql8.0

下载mysql安装包 :wget https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm

centos8 yum 安装mysql8.0

将下载好的安装包挂载到本地:yum localinstall mysql80-community-release-el8-1.noarch.rpm

centos8 yum 安装mysql8.0

查看是否挂载成功:yum repolist enabled | grep "mysql.*-community.*"

centos8 yum 安装mysql8.0

禁用centos8.0自带的mysql模块:yum module disable mysql

centos8 yum 安装mysql8.0

安装mysql:yum install mysql-community-server

centos8 yum 安装mysql8.0

启动mysql服务service mysqld start
查看mysql服务启动状态service mysqld status

centos8 yum 安装mysql8.0

mysql服务相关命令

启动服务:service mysqld start
停止服务:service mysqld stop
重启服务:service mysqld restart
查看服务状态:service mysqld status

设置mysql开机自启:
systemctl enable mysqld
systemctl daemon-reload

修改mysql密码并开放远程连接

查看mysql安装时生成的随机密码:grep 'temporary password' /var/log/mysqld.log

centos8 yum 安装mysql8.0

登录mysql

mysql -uroot -p'刚获取到的随机密码'

安装mysql后第一次登录需要修改密码

ALTER USER 'root' @'localhost' IDENTIFIED BY '你的密码';

开放mysql远程访问

创建权限记录:
CREATE user 'root'@'%' IDENTIFIED BY 'root123';

授权:
GRANT ALL PRIVILEGES ON *.* TO 'root' @'%' WITH GRANT OPTION;

修改密码过期策略:
ALTER USER 'root' @'localhost' IDENTIFIED BY '你的密码' PASSWORD EXPIRE NEVER;

重新修改密码:
ALTER USER 'root' @'%' IDENTIFIED WITH mysql_native_password BY '你的密码';

刷新权限:
FLUSH PRIVILEGES;

centos8 yum 安装mysql8.0

上一篇:Android 调用系统分享文字、图片、文件,可直达微信、朋友圈、QQ、QQ空间、微博


下一篇:sed练习-课后练习