Mysql8.0+CentOS8.0安装

Mysql8.0+CentOS8.0安装

​ 由于MySQL版本不兼容原因,你需要安装MySQL5.7,而不是安装MySQL8,但是Centos8默认是安装MySQL8的,因为Centos8的AppStream仓库只包含MySQL8的包

环境

系统版本


mysql版本:

linux版本: CentOS 8


操作

yum安装mysql服务

yum install mysql-server

检查是否已经设置为开机启动MySQL服务

[root@localhost ~]# systemctl list-unit-files | grep mysqld
mysqld.service                                                         disabled 
mysqld@.service                                                        disabled 

设置开机启动

[root@localhost ~]# systemctl enable mysqld.service 
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
# double check
[root@localhost ~]# systemctl list-unit-files|grep mysqld
mysqld.service                                                         enabled  
mysqld@.service                                                        disabled 

查看是否启动MySQL服务

[root@localhost ~]# ps -ef | grep mysql
root       34198    3968  0 06:01 pts/1    00:00:00 grep --color=auto mysql
[root@localhost ~]# 

修改root用户密码

[root@localhost ~]# mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
# 登录报错
[root@localhost mysql]# systemctl start mysqld.service 
[root@localhost mysql]# ps -ef | grep 'mysql'
mysql      34528       1  5 06:11 ?        00:00:00 /usr/libexec/mysqld --basedir=/usr
root       34609    3968  0 06:11 pts/1    00:00:00 grep --color=auto mysql
# 再次登录, 直接回车,没有密码
[root@localhost ~]# mysql -uroot -p
Enter password: 


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'root' ;
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

mysql> 

创建一个新用户

mysql> create user mysql identified with mysql_native_password by 'mysql';
Query OK, 0 rows affected (0.00 sec)

# 删除用户
delete from mysql.user where Host ='localhost' and User = 'username';
drop user username;
# 授权
mysql> grant all on *.* to 'mysql'@'%';
Query OK, 0 rows affected (0.01 sec)
# 刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

开通3306端口

[root@localhost man]# firewall-cmd --add-port=3306/tcp --permanent 
success

[root@localhost man]# firewall-cmd --reload 
success

测试连接

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

岁月玲珑

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值