MySQL的社区发布 MySQL 5.7开发版本 。它可在MySQL的官方网站看到信息。在这篇文章中,我们正在使用的CentOS 6.3 64位系统。对于其他操作系统版本(像:Windows)您可以从下载文件
在这里 。同时在本教程中更改所有的rpm名称。
第1步:从MySQL下载RPMs包
从MySQL CDN网络使用下面的下面的命令,下载需要的rpm文件。
对于32位系统:
# cd /opt/
# wget http://cdn.mysql.com/Downloads/MySQL-5.7/MySQL-server-5.7.2_m12-1.el6.i686.rpm
# wget http://cdn.mysql.com/Downloads/MySQL-5.7/MySQL-client-5.7.2_m12-1.el6.i686.rpm
# wget http://cdn.mysql.com/Downloads/MySQL-5.7/MySQL-shared-5.7.2_m12-1.el6.i686.rpm
对于64位系统:
# cd /opt/
# wget http://cdn.mysql.com/Downloads/MySQL-5.7/MySQL-server-5.7.2_m12-1.el6.x86_64.rpm
# wget http://cdn.mysql.com/Downloads/MySQL-5.7/MySQL-client-5.7.2_m12-1.el6.x86_64.rpm
# wget http://cdn.mysql.com/Downloads/MySQL-5.7/MySQL-shared-5.7.2_m12-1.el6.x86_64.rpm
第2步:安装MySQL RPMs
安装使用rpm命令行工具下载rpms。
对于32位系统:
# rpm -ivh MySQL-server-5.7.2_m12-1.el6.i686.rpm
# rpm -ivh MySQL-client-5.7.2_m12-1.el6.i686.rpm
# rpm -ivh MySQL-shared-5.7.2_m12-1.el6.i686.rpm
对于64位系统:
# rpm -ivh MySQL-server-5.7.2_m12-1.el6.x86_64.rpm
# rpm -ivh MySQL-client-5.7.2_m12-1.el6.x86_64.rpm
# rpm -ivh MySQL-shared-5.7.2_m12-1.el6.x86_64.rpm
第3步:启动MySQL服务
安装rpms包后使用下面的命令来启动mysql服务。
# /etc/init.d/mysql start
Starting MySQL.. SUCCESS!
第4步:初始MySQL配置
执行
mysql_secure_installation脚本并按照向导。它会提示输入根口令。要获取临时root密码检查“ /root/.mysql_secret '文件
# /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL THE STEPS FOLLOWING THIS IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the
current password for the root user. If you've just installed
MySQL, and you haven't set the root password yet, the
password will be blank, so you should just press enter here.
Enter password: [ Get password from '/root/.mysql_secret' ]
The existing password for the user account has expired. Please set a new password.
New password:
Re-enter new password:
OK, successfully used password, moving on...
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy.
Please enter 0 for LOW, 1 for MEDIUM and 2 for STRONG: 2
Setting the root password ensures that nobody can log into
the MySQL root user without the proper authorisation.
You already have a root password set.
Strength of the password: 50
Change the root password? (Press y|Y for Yes, any other key for No) : n
... skipping.
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.. Moving on..
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
Done.. Moving on..
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
- 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) : y
... Success!
All done! If you've completed all of the above steps, your
MySQL installation should now be secure.
第5步:登录到MySQL
恭喜!您已成功安装了MySQL 5.7。让使用root访问权限登录到MySQL并尝试创建一个数据库。
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 6
Server version: 5.7.2-m12 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>
创建使用下面的命令一个数据库。
mysql> create database dummydb;
Query OK, 1 row affected (0.01 sec)
第6步:检查版本的MySQL
验证您的系统上安装的MySQL版本。下面的命令会显示已安装的MySQL版本。
# mysql -V
mysql Ver 14.14 Distrib 5.7.2-m12, for Linux (x86_64) using EditLine wrapper