yum安装mysql及mysql配置
MySQL yum库提供了一个简单的和方便的方法来安装和更新MySQL相关的软件包到最新版本。
参考文档:http://dev.mysql.com/downloads/repo/yum/
MySQL yum库支持的平台有:
Red Hat Enterprise Linux 7 / Oracle Linux 7
Red Hat Enterprise Linux 6 / Oracle Linux 6
Red Hat Enterprise Linux 5 / Oracle Linux 5
Fedora 21, 22 and 23
MySQL yum库包括最新的软件包有:
MySQL 5.7 (GA)
MySQL 5.6 (GA)
MySQL 5.5 (GA - Red Hat Enterprise Linux and Oracle Linux Only)
MySQL Workbench
MySQL Fabric
MySQL Router
MySQL Utilities
MySQL Connector / ODBC
MySQL Connector / Python
安装命令
RHEL7/CentOS7/Oracle linux7:
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
RHEL6/CentOS6/Oracle linux6:
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
RHEL5/CentOS5/Oracle linux5:
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el5-5.noarch.rpm
Fedora
Fedora20
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-fc20-5.noarch.rpm
Fedora19
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-fc19-5.noarch.rpm
Fedora18
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-fc18-5.noarch.rpm
安装完默认启用的是mysql5.6,可以自行更改为5.5或者5.7,更改方法vi /etc/yum.repos.d/mysql-community.repo
,更改如下配置:
# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
#默认启用5.6
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
如需要使用mysql 5.7:
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
#如需启动5.7,将enabled改为1,并将5.6的该选项改为0
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
上面的步骤是安装mysql相关的软件包,需要启用mysql还需要安装mysql的服务器
yum install mysql-community-server
启动mysql
service mysqld start
设置Mysql开机启动
chkconfig mysqld on
设置Mysql远程访问
grant all privileges on *.* to 'admin'@'%' identified by '123456' with grant option;
注:admin
为数据库用户名,123456
为密码,@'%'表示允许任何IP连接数据库。该操作在数据库命令下进入mysql这个数据库进行。后面的分号也不要忘了哦。
最后重新启动服务就可以了
service mysqld restart