CentOS7 安装mysql8


 

与CentOS7对应的是源为

https://repo.mysql.com/mysql84-community-release-el7-1.noarch.rpm

使用包管理器RPM安装

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023

rpm -Uvh https://repo.mysql.com/mysql84-community-release-el7-1.noarch.rpm

yum安装

yum -y install mysql-community-server

查看安装位置并启动

[root@localhost ~]# whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/man/man1/mysql.1.gz
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl enable mysqld
[root@localhost ~]# systemctl status mysqld

查看 MySQL 服务进程

[root@localhost ~]# ps axj | grep mysqld
     1   6085   6085   6085 ?            -1 Ssl     27   0:03 /usr/sbin/mysqld
  3818   6179   6178   3818 pts/0      6178 R+       0   0:00 grep --color=auto mysqld

登录 MySQL

查看配置文件/etc/my.cnf

cat /etc/my.cnf

log-error 的内容 /var/log/mysqld.log 就是 MySQL 日志文件的路径

log-error=/var/log/mysqld.log
[root@localhost ~]# grep "temporary password" /var/log/mysqld.log
2024-12-12T05:54:36.633865Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Ukzur#ajq2U_
[root@localhost ~]# mysql -u root -p

修改密码

alter user 'root'@'localhost' identified by 'Abcd1234_efghi‘

注意,密码有要求,例如包括‘_’符号等,不然可能会出现

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值