当前位置:   article > 正文

【原创】CentOS8安装MySQL服务器

centos8安装mysql

查找系统中mysql残余

find / -name mysql
  • 1

接下来把找到的都删除掉

rm  -rf /var/lib/selinux/targeted/active/modules/100/mysql
rm -rf /usr/share/selinux/targeted/default/active/modules/100/mysql
  • 1
  • 2

检查Mysql安装包

yum search mysql
  • 1

安装

yum install -y mysql-server
  • 1

设置Mysql服务自动启动

systemctl enable mysqld
systemctl start mysqld
  • 1
  • 2

检查服务器状态

[root@078SeatDB ~]# systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-06-07 10:13:00 CST; 45min ago
  Process: 1394 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 1113 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
  Process: 1062 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 1150 (mysqld)
   Status: "Server is operational"
    Tasks: 38 (limit: 24726)
   Memory: 456.7M
   CGroup: /system.slice/mysqld.service
           └─1150 /usr/libexec/mysqld --basedir=/usr

Jun 07 10:12:57 078SeatDB systemd[1]: Starting MySQL 8.0 database server...
Jun 07 10:13:00 078SeatDB systemd[1]: Started MySQL 8.0 database server.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

登录数据库(默认无密码)

mysql
  • 1

修改root密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'aBC12345!';
exit
  • 1
  • 2

再次登录数据库

 mysql -u root -paBC12345!
 exit
  • 1
  • 2

添加用户

create user zmrbak identified by '1234';
  • 1

为用户创建数据库,授权

create database libVisits;
grant all privileges on libVisits.* to 'zmrbak'@'%' ;
grant select on mysql.* to 'zmrbak'@'%' ;
flush privileges;
  • 1
  • 2
  • 3
  • 4

修改用户密码

alter user 'zmrbak'@'%' IDENTIFIED by 'ABC23456'
  • 1

设置防火墙

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
  • 1
  • 2

接下来,就可以远程通过zmrbak来访问这个Mysql数据库了。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/301312
推荐阅读
相关标签
  

闽ICP备14008679号