Centos 6.5安装配置mysql

虚拟机安装的Centos 6.5 x64
本机 Ubuntu 14.04 x64

可以到mysql官网上去下载,不过需要翻墙,登陆,比较麻烦
推荐mysql下载地址
http://ftp.ntu.edu.tw/MySQL/Downloads

笔者下载的
MySQL-5.6.32-1.el6.x86_64.rpm-bundle.tar
解压之后如图

Centos 6.5安装配置mysql_第1张图片

启动终端进入解压目录

scp -r * [email protected]:~/

可以通过命令一个一个安装

rpm -ivh xxx.rpm

可能出现的相关错误
1.出现

error: Failed dependencies:
    libnuma.so.1()(64bit) is needed by MySQL-server-5.6.32-1.el6.x86_64
    libnuma.so.1(libnuma_1.1)(64bit) is needed by MySQL-server-5.6.32-1.el6.x86_64
    libnuma.so.1(libnuma_1.2)(64bit) is needed by MySQL-server-5.6.32-1.el6.x86_64

需要安装numactl

yum install numactl

2.出现

error: Failed dependencies:
    /usr/bin/perl is needed by MySQL-server-5.6.32-1.linux_glibc2.5.x86_64

需要安装perl

yum install perl

3.出现

Preparing...                ########################################### [100%]
    file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.32-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
    file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.32-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
    file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.32-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
    file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.32-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
...

需要移除之前的libs

rpm -qa|grep mysql
#mysql-libs-5.1.71-1.el6.x86_64
rpm -e mysql-libs-5.1.71-1.el6.x86_64 --nodeps
#或者直接
yum -y remove mysql-libs-*

笔者的安装脚本如下

yum -y remove mysql-libs-*
yum install perl
yum install numactl

rpm -ivh MySQL-client-5.6.32-1.el6.x86_64.rpm
rpm -ivh MySQL-devel-5.6.32-1.el6.x86_64.rpm
rpm -ivh MySQL-shared-5.6.32-1.el6.x86_64.rpm
rpm -ivh MySQL-embedded-5.6.32-1.el6.x86_64.rpm
rpm -ivh MySQL-shared-compat-5.6.32-1.el6.x86_64.rpm
rpm -ivh MySQL-test-5.6.32-1.el6.x86_64.rpm
rpm -ivh MySQL-server-5.6.32-1.el6.x86_64.rpm

安装好mysql-server之后
会出现这样一段话

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.

大概意思就是 一个随机的密码已经生成 可以在 '/root/.mysql_secret'. 中找到

cat /root/.mysql_secret
# The random password set for the root user at Mon Aug  1 17:07:32 2016 (local time): Vt5dWVuEDafMVmsW

这个Vt5dWVuEDafMVmsW就是随机的密码
启动服务

service mysql start

修改密码数据库密码

mysqladmin -uroot -pVt5dWVuEDafMVmsW password 'haoroot'
#修改成功之后可以登陆了
mysql -uroot -phaoroot

开启远程连接

默认mysql是没有开启远程连接的
为安全起见,看同事们都是ssh远程登陆之后直接操作数据库的
1.开启mysql的远程连接

mysql>grant all privileges on *.*  to  'root'@'%'  identified by 'haoroot'  with grant option;
mysql>flush privileges;

开启防火墙端口

#vim /etc/sysconfig/iptables  
#在-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT之后添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 7575 -j ACCEPT

重启防火墙

service iptables restart 

Navicat新建连接

Centos 6.5安装配置mysql_第2张图片

2.SSH远程连接
建议先看看之前的一篇《SSH远程登陆》

Centos 6.5安装配置mysql_第3张图片

这里的localhost指的是连上服务器之后的localhost

Centos 6.5安装配置mysql_第4张图片

连接之后的信息

Centos 6.5安装配置mysql_第5张图片

注意:

ubuntu下可以使用命令查看远程的版本
sudo apt-cache showpkg mysql-server

你可能感兴趣的:(Centos 6.5安装配置mysql)