Centos7.2下mysql5.7的安装(yum)

时间:2022-09-06 10:03:08

配置yum源

安装

  • [root@iZ2ze9ridy7gp330brwunrZ /]# yum install mysql-community-server
  • [root@iZ2ze9ridy7gp330brwunrZ /]# systemctl start mysqld
  • [root@iZ2ze9ridy7gp330brwunrZ /]# systemctl status mysqld

开机自启动

systemctl enable mysqld
systemctl daemon-reload

寻找默认密码

  • [root@iZ2ze9ridy7gp330brwunrZ /]# grep ‘temporary password’ /var/log/mysqld.log
    Centos7.2下mysql5.7的安装(yum)

更改密码

  • [root@iZ2ze9ridy7gp330brwunrZ /]# mysql -uroot -p
  • mysql> set password for ‘root’@’localhost’=password(‘NewPwd4!@#’);

允许远程连接

  • GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘your_root_password’

编码修改

  • [root@iZ2ze9ridy7gp330brwunrZ /]# vim /etc/my.cnf
    [mysqld]
    character_set_server=utf8
    init_connect=’SET NAMES utf8’

收工!!