下载MySQL YUM源(官网下载)
wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
查看包里面的内容
[[email protected] ~]# rpm -qplmysql57-community-release-el6-7.noarch.rpm
/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
/etc/yum.repos.d/mysql-community-source.repo
/etc/yum.repos.d/mysql-community.repo
查看yum列表
yum list |grep mysql
安装MySQL
yum install mysql-client mysql-server
启动MySQL服务
[[email protected] ~]# service mysqld start
查看初始密码
[[email protected] ~]# grep ‘temporary password‘/var/log/mysqld.log
进行初始的安全设置
[[email protected] ~]# cd /usr/bin/
[[email protected] bin]# mysql_secure_installation
设置如下内容:
重置密码
删除匿名用户
删除测试数据库
关闭root用户的远程登录
[[email protected] bin]# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
The existing password for the user accountroot has expired. Please set a new password.
New password:
Re-enter new password:
...Failed! Error: Your password does not satisfy the current policy requirements
New password:
Re-enter new password:
The ‘validate_password‘ plugin is installedon the server.
The subsequent steps will run with theexisting configuration
of the plugin.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Yfor Yes, any other key for No) : y
New password:
Re-enter new password:
Estimated strength of the password: 100
Do you wish to continue with the passwordprovided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has ananonymous user,
allowing anyone to log into MySQL withouthaving to have
a user account created for them. This isintended only for
testing, and to make the installation go abit smoother.
You should remove them before moving into aproduction
environment.
Remove anonymous users? (Press y|Y for Yes,any other key for No) : y
Success.
Normally, root should only be allowed toconnect from
‘localhost‘. This ensures that someonecannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Yfor Yes, any other key for No) : n
...skipping.
By default, MySQL comes with a databasenamed ‘test‘ that
anyone can access. This is also intendedonly for testing,
and should be removed before moving into aproduction
environment.
Remove test database and access to it?(Press y|Y for Yes, any other key for No) : n
...skipping.
Reloading the privilege tables will ensurethat all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y forYes, any other key for No) : y
Success.
All done!(提示全部设置完毕)
然后你就可以享受MySQL带来的乐趣了。