centos安装mysql

由于centOS7不支持在线安装,因此只能手动安装;

Centos认安装MariaDB数据库MysqL有冲突,安装MysqL前必须卸载次数据库

rpm -q ...

1.下载MysqL

http://dev.mysql.com/downloads/mysql/

服务端:(MysqL-community-server-5.7.14-1.el7.i686.rpm)

客户端:(mysql-community-client-5.7.14-1.el7.i686.rpm)

2.安装MysqL服务端跟客户端

#列出所有被安装的rpm package
rpm -qa | grep mariadb

#卸载

rpm -e mariadb-libs-5.5.37-1.el7_0.x86_64

错误:依赖检测失败: libMysqLclient.so.18()(64bit) 被 (已安裝) postfix-2:2.10.1-6.el7.x86_64 需要 libMysqLclient.so.18(libMysqLclient_18)(64bit) 被 (已安裝) postfix-2:2.10.1-6.el7.x86_64 需要

#强制卸载,因为没有--nodePS

rpm -e --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64

#安装MysqL5.5.39的rpm包

rpm -ivh /home/liwei/MysqL-server-5.5.39-2.el6.x86_64.rpm

rpm -ivh /home/liwei/MysqL-client-5.5.39-2.el6.x86_64.rpm

#拷贝配置文件

cp /usr/share/MysqL/my-medium.cnf /etc/my.cnf,改名为my.cnf作为MysqL配置文件

#修改响应的配置文件

vim/etc/my.cnf

#把MysqL的data拷贝到制定的目录

mv /var/lib/MysqL /home/MysqL/data/

3.启动MysqL

#/usr/sbin/MysqL &

可以将下面的内容添加my.cnf

件中:

[MysqLd]

user=MysqL

再次启动

原因:

在虚拟机中安装了CentOS时安装了Nami版的Rendmine,没有设置MysqL自动启动,手动启动时出现Please read "Security" section of the manual to find out how to run MysqLd as root!错误,根据提示,查了 /opt/redmine-1.2.1-1/MysqL/docs/MysqL.infoSecurity部分,发现是因为MysqL为了安全,不希望root用户直接启动MysqL

在虚拟机中安装了CentOS时安装了Nami版的Rendmine,没有设置MysqL自动启动,手动启动时出现Please read "Security" section of the manual to find out how to run MysqLd as root!错误,根据提示,查了 /opt/redmine-1.2.1-1/MysqL/docs/MysqL.infoSecurity部分,发现是因为MysqL为了安全,不希望root用户直接启动MysqL。下面是文档中的原文:

*Never run the MysqL server as the Unix `root' user. This is
extremely dangerous,because any user with the `FILE' privilege is
able to cause the server to create files as `root' (for example,
`~root/.bashrc'). To prevent this,*Note `MysqLd': MysqLd. refuses
to run as `root' unless that is specified explicitly using the
`--user=root' option.

永远不要使用root帐号启动MysqL Server。这样做很微笑,因为拥有FILE'权限的用户会使得MysqL Server使用root帐户创建文件(比如,~root/.bashrc),为了防止类似的事情发生,MysqLd认拒绝用户使用root帐户启动,但root用户可以通过在命令后面加上"--user=root"选项来强行启动MysqLd

*Note `MysqLd': MysqLd. can (and should) be run as an ordinary,
unprivileged user instead. You can create a separate Unix account
named `MysqL' to make everything even more secure. Use this
account only for administering MysqL. To start *Note `MysqLd':
MysqLd. as a different Unix user,add a `user' option that
specifies the user name in the `[MysqLd]' group of the `my.cnf'
option file where you specify server options. For example:

[MysqLd]
user=MysqL

与使用root用户启动MysqLd相比,更好的方法是使用一个普通的、没有高级权限的用户帐户允许MysqLd,例如创建一个名为MysqL用户帐户来专门管理MysqL。使用其帐启

MysqL方法是在MysqLd命令后面加上一个用户选项,这个用户属于MysqLd用户组并且位于my.cnf配置文件中。例如在创建MysqL帐户后, user=MysqL

This causes the server to start as the designated user whether you
start it manually or by using *Note `MysqLd_safe': MysqLd-safe. or
*Note `MysqL.server': MysqL-server. For more details,see *Note
changing-MysqL-user::.

这个选项可以使你使用指定的用户帐户启动MysqL,无论是MysqLd_safe还是MysqL.server命令,都可以使用。

Running *Note `MysqLd': MysqLd. as a Unix user other than `root'
does not mean that you need to change the `root' user name in the
`user' table. _User names for MysqL accounts have nothing to do
with user names for Unix accounts_.

不要使用Unixroot用户启动并不意味着你要修改MysqL中的user表中的root用户名,因为Unixroot帐户和MysqLroot帐户没有什么关系。

4.远程登录

A.开启远程登录

Mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'a1b2c3' WITH GRANT OPTION;

FLUSH PRIVILEGES;

#service MysqL stop;

#service MysqL start;

B.关闭防火墙

Centos7认开发firewall服务

ystemctl stop firewalld.service #停止firewall

#systemctl disable firewalld.service #禁止firewall开机启动

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native