阿里云安裝Mysql數(shù)據(jù)庫(kù)
網(wǎng)上攻略太多了,很多是不符合自己安裝的環(huán)境的抠璃,所以還是要因具體的環(huán)境而定
阿里云服務(wù)器 :Linux 3.10.0-693.2.2.el7.x86_64 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Mysql版本 :mysql-5.6.42-linux-glibc2.12-x86_64
下載地址 : MySQL官網(wǎng)
- 卸載參考:
a)查看系統(tǒng)中是否以rpm包安裝的mysql
[plain] view plaincopy
[root@linux ~]# rpm -qa | grep -i mysql
MySQL-server-5.1.49-1.glibc23
MySQL-client-5.1.49-1.glibc23
有就卸載
[plain] view plaincopy
[root@linux ~]# rpm -e MySQL-client-5.1.49-1.glibc23
[root@linux ~]# rpm -e MySQL-server-5.1.49-1.glibc23
b)查看有沒有mysql服務(wù)
[plain] view plaincopy
[root@linux ~]# chkconfig --list | grep -i mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
刪除mysql服務(wù)
[plain] view plaincopy
[root@linux ~]# chkconfig --del mysql
c)刪除分散mysql文件夾
[plain] view plaincopy
[root@linux ~]# whereis mysql
mysql: /usr/lib/mysql /usr/share/mysql
分別刪除
[plain] view plaincopy
[root@linux lib]# rm -rf /usr/lib/mysql/
[root@linux lib]# rm -rf /usr/share/mysql
通過以上幾步站楚,mysql應(yīng)該已經(jīng)完全卸載干凈了
2.下載安裝
參考官方:使用通用二進(jìn)制文件在Unix / Linux上安裝MySQL
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
這里報(bào)了個(gè)錯(cuò)
# scripts/mysql_install_db --user=mysql
FATAL ERROR: please install the following Perl modules before executing scripts/mysql_install_db:
Data::Dumper
解決方法 :安裝autoconf庫(kù)
命令:yum-y install autoconf //此包安裝時(shí)會(huì)安裝Data:Dumper模塊
或參考:Mysql官方的Perl安裝說明
# yum-y install autoconf
-bash: yum-y: command not found
# rpm -qa |grep yum
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-plugin-fastestmirror-1.1.31-42.el7.noarch
yum-3.4.3-154.el7.centos.noarch
# yum
...
# yum install autoconf
...
這里差點(diǎn)被坑,以為yum沒有安裝搏嗡,去掉-y安裝窿春,不太懂為什么
繼續(xù)報(bào)錯(cuò)
# scripts/mysql_install_db --user=mysql
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
下載
# yum install libaio* -y
3.使用密碼登錄mysql賬號(hào):mysql -uroot -p
修改root密碼:SET PASSWORD = PASSWORD('123456');
4.開啟遠(yuǎn)程訪問
mysql -uroot –p123456
設(shè)置遠(yuǎn)程訪問(使用root密碼):
grant all privileges on *.* to 'root' @'%' identified by '123456';
flush privileges;
防火墻打開3306端口
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables status
這篇參考也可以看看,很有幫助:
【MySQL】Linux下MySQL 5.5采盒、5.6和5.7的RPM旧乞、二進(jìn)制和源碼安裝-博客-云棲社區(qū)-阿里云