centos6.5_64安装MySQL5.7
------------------------------------
配置:
/etc/hosts, IP与主机名
/etc/sysconfig/network 主机名
防止mysql启动初始化报错
------------------------------------
删除系统默认安装的mysql及其依赖
yum -y remove mysql-libs.x86_64
下载yum源(mysql5.7)
wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm --no-check-certificate
yum install mysql-community-release-el6-5.noarch.rpm
安装成功后,可以看到/etc/yum.repos.d/目录下增加了以下两个文件
ls /etc/yum.repos.d
mysql-community-source.repo
mysql-community.repo
查看mysql的安装源有哪些以及是否可用
[root@synjones mysql]# yum repolist enabled | grep mysql
mysql-connectors-community MySQL Connectors Community 66
mysql-tools-community MySQL Tools Community 68
mysql56-community MySQL 5.6 Community Server 474
mysql57-community-dmr MySQL 5.7 Community Server Development Milesto 291
====如显示无5.7版本,可修改/etc/yum.repos.d/mysql-community.repo
# Note: MySQL 5.7 is currently in development. For use at your own risk.
# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/
[mysql57-community-dmr]
name=MySQL 5.7 Community Server Development Milestone Release
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
------------------------------------------------修改后安装mysql
yum install mysql-community-server
---安装后检查MYSQL版本
[root@synjones mysql]# rpm -qa |grep mysql
mysql-community-release-el6-5.noarch
mysql-community-libs-5.7.24-1.el6.x86_64
mysql-community-common-5.7.24-1.el6.x86_64
mysql-community-server-5.7.24-1.el6.x86_64
mysql-community-client-5.7.24-1.el6.x86_64
[root@synjones mysql]# mysql -V
mysql Ver 14.14 Distrib 5.7.24, for Linux (x86_64) using EditLine wrapper
===============================如遇到启动报错:
MySQL Daemon failed to start.?
Starting mysqld: [FAILED]
处理方法:
rm -fr /var/lib/mysql/*
rm /var/lock/subsys/mysqld
==============================一般为卸载mysql重新安装后会出现。
配置/etc/my.cnf
[root@synjones ~]# cat /etc/my.cnf
======================================my.cnf配置文件
[client]
default-character-set=utf8
[mysqld]
#datadir为MYSQL数据文件存放路径
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
#user=mysql
character-set-server=utf8
collation-server=utf8_general_ci
#此配置启用,在MYSQL登录不用密码,更改后需注销此配置
#skip-grant-tables
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
======================================my.cnf配置文件
mysql登录后修改密码
======5.7下使用
update mysql.user set authentication_string=password('root密码') where user='root' ;
======5.7使用
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update mysql.user set authentication_string=password('root密码') where user='root' ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
====授权任意访问
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
创建mysq实例,并授权远程访问
mysql> CREATE DATABASE IF NOT EXISTS iisp DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON iisp.* TO iisp@'%' IDENTIFIED BY 'root密码';
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)