虛擬機(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)這樣一段話(huà)
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