Centos7系统安装MySQL

Step 1 - Add the new MySQL repository to the CentOS 7 server with this yum command.

yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

 

Step 2 - Install MySQL 5.7

yum -y install mysql-community-server

 

Step 3 - Start MySQL and Enable Start at Boot Time

systemctl start mysqld
systemctl enable mysqld

 

Step 4 - Configure the MySQL Root Password

On CentOS 7, MySQL will generate a strong default password when MySQL is started the first time, the default password is shown in the mysqld.log file. You can use the grep command below for showing the default MySQL password.

grep 'temporary' /var/log/mysqld.log

You will see default MySQL root password, and we should set a new default password now.

 

Connect to the MySQL shell with the default password.

mysql -u root -p
TYPE DEFAULT PASSWORD

Now replace the default password with a new and strong password, in my case, I will set the password 'Newhakase-labs123@' with the MySQL query below.

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Newhakase-labs123@';

THEN
flush privileges; (Don't forget)

The default password has been changed.

 

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root-yuan1234@';

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值