yum安装
wget https://repo.mysql.com/mysql57-community-release-el7.rpm
yum -y install mysql57-community-release-el7.rpm
升级MySql的GPG(防止报错)
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
安装MySQL源
yum -y install mysql-community-server
启动,并查看运行状态
systemctl start mysqld
systemctl status mysqld
查看MySql的版本(截图)
rpm -qa | grep mysql
mysql --help | grep Distrib
编辑mysql配置文件
vim /etc/my.cnf
在最后一行添加如下:
port=4444
重启MySql服务
systemctl restart mysqld
查看Mysql的端口(截图)
netstat -anp | grep mysql
扩展#
查看Mysql的用户root的密码
grep "password" /var/log/mysqld.log
2023-05-17T08:29:49.794855Z 1 [Note] A temporary password is generated for root@localhost: %r,/=oAgZ1kt
(localhost:冒号后面的就是密码)
连接数据库
[root@ecs-wangbiao ~]# mysql -uroot -p
Enter password: %r,/=oAgZ1kt
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.7.42
更改root的密码(密码改成root)
alter user 'root'@'localhost' identified by 'root';
set global validate_password_policy=0;
set global validate_password_length=1;
alter user 'root'@'localhost' identified by 'root';
exit