CentOS8 安装 MySQL8(yum)

软件环境

  • CentOS Linux release 8.1.1911 (Core)
  • mysql80-community-release-el8-1.noarch.rpm

卸载之前的安装

rpm -qa | grep -i mysql

# 强力删除,对相关依赖的文件也进行强力删除
rpm -e --nodeps 软件名

安装服务端(mysql-server)

wget https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm

rpm -ivh mysql80-community-release-el8-1.noarch.rpm
yum install mysql-server

查看是否安装成功

ps -ef | grep mysql

cat /etc/group | grep mysql

cat /etc/password | grep mysql

mysqladmin --version

设置开机启动

systemctl list-unit-files|grep mysqld

# 设置开机启动
systemctl enable mysqld.service

systemctl list-unit-files|grep mysqld

启动服务

# 查看是否启动MySQL服务
ps -ef|grep mysql

#启动服务
systemctl start mysqld.service 

停止、重启服务

# 停止服务
systemctl stop mysqld

# 重启服务
systemctl restart mysqld

# 查看服务
systemctl status mysqld

安全设置

mysql_secure_installation

重置密码

# 选择 mysql 数据库
mysql> use mysql;

# 清空旧密码
mysql> update user set authentication_string='' where user='root';

# 重置新密码
mysql> alter user 'root'@'localhost' identified by '11111111';

赋权远程客户端

# 创建账户
create user 'root'@'%' identified by '11111111';

# 赋予权限
# with grant option 选项表示该用户可以将自己拥有的权限授权给别人
grant all privileges on *.* to 'root'@'%' with grant option;

# 赋权生效,将当前 user 和 privilige 表中的用户信息/权限设置提取到内存
flush privileges;

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。