rpm安装mysql5.6
rpm -qa | grep -i mysql
#如果安装了先卸载旧的版本
yum -y remove mysql...
2.下载需要的安装包,下载地址
http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.20-1.el6.x86_64.rpm
http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-devel-5.6.20-1.el6.x86_64.rpm
http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.20-1.el6.x86_64.rpm
或者到官网下载完整包http://dev.mysql.com/downloads/mysql
3.开始安装
tar xvf MySQL-5.6.21-1.el6.x86_64.rpm-bundle.tar yum -y localinstall *.rpm
A random root password has been set. You will find it in '/root/.mysql_secret'. A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER ! You will find that password in '/root/.mysql_secret'. You must change that password on your first connect, no other statement but 'SET PASSWORD' will be accepted. See the manual for the semantics of the 'password expired' flag. Also, the account for the anonymous user has been removed. In addition, you can run: /usr/bin/mysql_secure_installation
安装完成后会有上面提示,MySQL5.6安装完成后会生成一个随机密码,密码保存在/root/.mysql_secret文件中
4.修改配置文件位置并做相关设置
cp /usr/share/mysql/my-default.cnf /etc/my.cnf vi /etc/my.cnf
#做如下配置
[client] port = 3306 default-character-set=utf8 [mysqld] port = 3306 character_set_server=utf8 character_set_client=utf8 collation-server=utf8_general_ci
#linux下mysql安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写
lower_case_table_names=1
#设置最大连接数,默认为 151,MySQL服务器允许的最大连接数16384
max_connections=1000 [mysql] default-character-set = utf8
5.初始化MySQL及设置密码。执行安装完成后的脚本,默认在以下路径
/usr/bin/mysql_install_db To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers.
根据提示,我们可以通过给出的提示做相关安全设置,执行如下脚本
/usr/bin/mysql_secure_installation Enter current password for root (enter for none): OK, successfully used password, moving on... You already have a root password set, so you can safely answer 'n'.
更改密码
Change the root password? [Y/n] y New password: Re-enter new password:
禁用匿名登录
Remove anonymous users? [Y/n] y ... Success!
禁用root用户远程登录,生产环境建议禁掉
Disallow root login remotely? [Y/n] y ... skipping.
删除test数据库,建议删掉
Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!
重新加载权限表
Reload privilege tables now? [Y/n] y ... Success! Thanks for using MySQL!
至此,MySQL5.6安装完成