一、下载MySQL5.7的yum源文件
网址:http://dev.mysql.com/downloads/repo/yum/
[root@me~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
二、安装下载的yum源
[root@me~]# rpm -Uvh mysql57-community-release-el7-7.noarch.rpm
三、yum安装MySQL
[root@me~]# yum install mysql-community-server
mysql5.7安装完成后会初始化一个root用户的默认密码
查找默认密码(当前默认密码是“/(=0RucLq*,I”):
[root@me ~]# grep 'temporary password' /var/log/mysqld.log 2015-11-10T11:57:30.004110Z 1 [Note] A temporary password is generated for root@localhost: /(=0RucLq*,I
四、启动MySQL服务
[root@me~]# service mysqld start
五、执行MySQL的安全配置向导“mysql_secure_installation”命令
执行该命令前必须先启动mysql服务不然提示:
Error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
Securing the MySQL server deployment. Enter password for user root: <——输入上面安装mysql时初始化的root密码(“/(=0RucLq*,I”) The existing password for the user account root has expired. Please set a new password.<——提示安装mysql时初始化的root密码已过期需要重新设置 New password: <——输入新的root密码(注意:密码至少8位字符,且必须包含大小写和特殊字符,不然在输完重复密码后提示密码不符合要求) Re-enter new password: <——重复新的root密码 Estimated strength of the password: 100 <——提示密码强度为100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y<——是否删除匿名用户 Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y<——是否禁止root远程登录 Success. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y<——是否删除test数据库 - Dropping test database... Success. - Removing privileges on test database... Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : ... skipping. All done! |
成功执行完“mysql_secure_installation”命令后MySQL5.7就安装成功了