首页  /  OS系统  /  Linux  /  CentOS7安装MySQL

CentOS7安装MySQL

 作者:白驹    来源:    浏览:112    日期:2021年3月20日  

CentOS7安装MySQL

一、下载安装mysql

1、下载并安装MySQL官方的 Yum Repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

2、安装Yum Repository

yum -y install mysql57-community-release-el7-10.noarch.rpm

3、开始安装MySQL服务器

yum -y install mysql-community-server

二、设置mysql

1、启动mysql

systemctl start  mysqld.service

2.查看mysql运行状态

#运行命令
systemctl status mysqld.service
#执行结果
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 六 2021-03-20 17:56:13 CST; 27s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 101746 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 101579 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 101749 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─101749 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

2.查找mysql默认密码

#运行命令
 grep "password" /var/log/mysqld.log
#执行结果
2021-03-20T09:56:06.077656Z 1 [Note] A temporary password is generated for root@localhost: hu=KriA9Qokl

3.进入mysql创建新的用户密码

mysql -u root -p hu=KriA9Qokl

4.创建修改mysql用户密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
#其中‘new password’替换成你要设置的密码,注意:密码设置必须要大小写字母数字和特殊符号(,/';:等),不然不能配置成功
  • 评论
  • 相关评论