安装环境:CentOS7 64位,安装MySQL5.7
一、安装 MySQL
1、配置YUM源
#下载mysql源安装包shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm#安装mysql源shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
shell> yum repolist enabled | grep "mysql.*-community.*"
2、安装MySQL
shell> systemctl start mysqld
3、启动MySQL服务
shell> systemctl start mysqld
查看MySQL的启动状态
shell>systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded(/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)Active: active(running) since 五 2016-06-24 04:37:37 CST;35min ago
Main PID:2888 (mysqld)CGroup:/system.slice/mysqld.service
└─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
6月24 04:37:36 localhost.localdomain systemd[1]: Starting MySQL Server...6月24 04:37:37 localhost.localdomain systemd[1]: Started MySQL Server.
4、开机启动
shell>systemctl enable mysqldshell> systemctl daemon-reload
5、修改root默认密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
shell> grep 'temporary password' /var/log/mysqld.log
shell>mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDE