本文為參考CentOS 7 RPM 安裝 MySQL5.7自己嘗試在CentOS上安裝MySQL5.7,記錄下來,方便自己以后查閱
1:環境
操作系統:CentOS Linux release 7.2.1511
MySQL版本:mysql-5.7.17-1
2:下載RPM安裝包
前往MySQL官網下載RPM安裝包,本文使用的版本是mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar
下載完成之后,將安裝包上傳至服務器,然后解壓tar xvf mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar
3:安裝
依次執行如下命令安裝
rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.17-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm
執行前三個命令順利成功,但是,執行第四個命令時,報錯
a:缺少perl,執行yum install perl命令安裝,大致錯誤如下
error: Failed dependencies:
/usr/bin/perl is needed by mysql-community-server-5.7.17-1.el7.x86_64.rpm
b:缺少libaio,前往http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm下載,執行rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm命令安裝,大致錯誤如下
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-5.7.17-1.el7.x86_64.rpm
然后,再次執行上述第四個命令,成功
4:數據庫初始化
執行mysqld --initialize --user=mysql命令初始化,初始化完成后,會生成一個root賬號密碼,位于/var/log目錄下的mysqld.log文件最后一行
現在,使用上述密碼啟動數據庫
systemctl start mysqld
mysql -uroot -p
5:修改密碼
alter user 'root'@'localhost' identified by 'new_password'
6:添加遠程用戶
使用如下sql添加遠程用戶
grant all privileges on *.* to 'account'@'%' identified by 'password' with grant option