1.wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm --no-check-certificate 獲取rpm 包
2. mv mysql-community-release-el6-5.noarch.rpm /home/liujun/ 將包移動到某個目錄下
3.yum localinstall mysql-community-release-el6-5.noarch.rpm
4. yum repolist all | grep mysql 查看安裝的依賴
5. /etc/yum.repos.d/mysql-community.repo 的設置如下,注意最后一欄 [mysql57-community-dmr]
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Note: MySQL 5.7 is currently in development. For use at your own risk.
# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/
[mysql57-community-dmr]
name=MySQL 5.7 Community Server Development Milestone Release
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
6.sudo yum install mysql-server
修改密碼:
在 /etc/my.cnf 后面加 skip-grant-tables 免密登錄
1.systemctl restart mysqld 重啟服務
2.mysql -u root -p 輸入密碼時直接按Enter鍵登錄
3.update mysql.user set authentication_string=password('xxx') where user='root' and host='localhost'; xxx 改為自己密碼
4.flush privileges 刷新
5.skip-grant-tables
6.systemctl restart mysqld 再重啟
命令:
1. rpm -qa | grep -i mysql 查詢mysql 安裝的依賴
2.yum install mysql-devel 安裝后有mysql 文件夾