安装准备
- 服务器环境:Centos 6 x86 (32位)
- 安装包:MysqL-5.7.19-1.el6.i686.rpm-bundle.tar
- 安装方式:rpm安装
- 下载地址:https://dev.mysql.com/downloads/mysql/
安装流程
1.检查系统是否已安装MariaDB
$ rpm -qa | grep mariadb
2.如果存在有,则通过下面命令卸载
$ rpm -e --nodeps xxxxxx
3.解压tar包,取得里面的rpm安装包
$ tar -xvf MysqL-5.7.19-1.el6.i686.rpm-bundle.tar MysqL-community-client-5.7.19-1.el6.i686.rpm MysqL-community-embedded-5.7.19-1.el6.i686.rpm MysqL-community-libs-5.7.19-1.el6.i686.rpm MysqL-community-libs-compat-5.7.19-1.el6.i686.rpm MysqL-community-common-5.7.19-1.el6.i686.rpm MysqL-community-server-5.7.19-1.el6.i686.rpm MysqL-community-devel-5.7.19-1.el6.i686.rpm MysqL-community-test-5.7.19-1.el6.i686.rpm MysqL-community-embedded-devel-5.7.19-1.el6.i686.rpm
4.在大多数情况下,你只需要安装MysqL-server和MysqL-client安装包就可以安装上一个标准功能的MysqL。但是RPM包有依赖关系,因此还要额外安装2个RPM包。依次执行以下命令:
$ rpm -ivh MysqL-community-common-5.7.19-1.el6.i686.rpm $ rpm -ivh MysqL-community-libs-5.7.19-1.el6.i686.rpm $ rpm -ivh MysqL-community-client-5.7.19-1.el6.i686.rpm $ rpm -ivh MysqL-community-server-5.7.19-1.el6.i686.rpm
5.安装完成后,MysqL5.7会默认分配一个随机密码到root用户,密码记录保存在 /var/log/MysqLd.log 文件下。
6.启动MysqLd服务
$ service MysqLd start
$ MysqL -uroot -p #登录成功后 MysqL>alter user 'root'@'localhost' identified by 'xxxxxx';
8.为了方便操作,开启远程连接
#给予任何主机访问数据库权限 (root是用户名,%是主机名或IP地址,这里的%代表任意主机或IP地址,你也可替换成任意其它用户名或指定唯一的IP地址) MysqL>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; #刷新权限 MysqL>flush privileges;
同时还要在防火墙上开放3306端口
$ /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT #保存修改 $ /etc/init.d/iptables save #重启防火墙 $ service iptables restart
9.修改字符集编码
编辑 /etc/my.cnf
[client] default-character-set=utf8 [MysqLd] character-set-server=utf8 collation-server=utf8_general_ci
10.重启MysqL服务
$ service MysqLd restart原文链接:https://www.f2er.com/centos/376655.html