Centos 6.5安裝配置mysql

虛擬機(jī)安裝的Centos 6.5 x64
本機(jī) Ubuntu 14.04 x64

可以到mysql官網(wǎng)上去下載,不過(guò)需要翻墻,登陸,比較麻煩
推薦mysql下載地址
http://ftp.ntu.edu.tw/MySQL/Downloads

筆者下載的
MySQL-5.6.32-1.el6.x86_64.rpm-bundle.tar
解壓之后如圖

啟動(dòng)終端進(jìn)入解壓目錄

scp -r * root@192.168.1.104:~/

可以通過(guò)命令一個(gè)一個(gè)安裝

rpm -ivh xxx.rpm

可能出現(xiàn)的相關(guān)錯(cuò)誤
1.出現(xiàn)

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.出現(xiàn)

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.出現(xiàn)

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之后
會(huì)出現(xiàn)這樣一段話

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.

大概意思就是 一個(gè)隨機(jī)的密碼已經(jīng)生成 可以在 '/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

這個(gè)Vt5dWVuEDafMVmsW就是隨機(jī)的密碼
啟動(dòng)服務(wù)

service mysql start

修改密碼數(shù)據(jù)庫(kù)密碼

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

開(kāi)啟遠(yuǎn)程連接

默認(rèn)mysql是沒(méi)有開(kāi)啟遠(yuǎn)程連接的
為安全起見(jiàn),看同事們都是ssh遠(yuǎn)程登陸之后直接操作數(shù)據(jù)庫(kù)的
1.開(kāi)啟mysql的遠(yuǎn)程連接

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

開(kāi)啟防火墻端口

#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新建連接

2.SSH遠(yuǎn)程連接
建議先看看之前的一篇《SSH遠(yuǎn)程登陸》

這里的localhost指的是連上服務(wù)器之后的localhost

連接之后的信息

注意:

ubuntu下可以使用命令查看遠(yuǎn)程的版本
sudo apt-cache showpkg mysql-server
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容