Centos 配置mysql

一、配置YUM源

http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm //下载mysql源安装包
yum -y localinstall mysql57-community-release-el7-8.noarch.rpm //安装mysql源
yum repolist enabled | grep "mysql.*-community.*" //检查mysql源是否安装成功
看到下图所示表示安装成功:

 

二、安装MySQL

yum install mysql-community-server //安装mysql

三、启动MySQL服

systemctl start mysqld         //启动MySQL服务
systemctl status mysqld //查看MySQL的启动状态

Centos 配置mysql_第1张图片

 

 

 四、开机启动

systemctl enable mysqld

systemctl daemon-reload

五、修改root本地登录密码

mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过

grep 'temporary password' /var/log/mysqld.log 找到root默认密码,然后登录mysql进行修改
grep 'temporary password' /var/log/mysqld.log //查找登陆mysql的随机密码
mysql -uroot -p //登陆mysql
输入随机密码进入mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'; // 设置新的登陆密码

 

 

 

 

 

 

 

 

 
 
 

 

你可能感兴趣的:(Centos 配置mysql)