1、前言mysql
直接「yum -y install mysql」安裝mysql,你會發現,安裝的是MariaDB,而且默認是5.5版本,所以若是咱們想控制版本,而須要下面的方法sql
2、安裝epel倉庫數據庫
yum -y install epel-releasevim
3、手動建立mysql的yum源app
[root@dabiaoge ~]# cd /etc/yum.repos.d/
[root@dabiaoge yum.repos.d]# vim mysq.repoide
[mysql-connectors-community] name=MySQL Connectors Community baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$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/7/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql57-community] name=MySQL 5.7 Community Server 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 [mysql-tools-preview] name=MySQL Tools Preview baseurl=http://repo.mysql.com/yum/mysql-tools-preview/el/7/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql-cluster-7.5-community] name=MySQL Cluster 7.5 Community baseurl=http://repo.mysql.com/yum/mysql-cluster-7.5-community/el/7/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql-cluster-7.6-community] name=MySQL Cluster 7.6 Community baseurl=http://repo.mysql.com/yum/mysql-cluster-7.6-community/el/7/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
4、安裝mysqlurl
[root@dabiaoge yum.repos.d]# yum -y install mysql-community-servercode
5、參看版本server
[root@dabiaoge yum.repos.d]# mysql -V
mysql Ver 14.14 Distrib 5.7.24, for Linux (x86_64) using EditLine wrapperssl
6、啓動數據庫,查看初始化密碼
[root@dabiaoge yum.repos.d]# systemctl start mysqld
[root@dabiaoge yum.repos.d]# cat /var/log/mysqld.log | grep root@localhost
2019-01-01T11:10:13.006233Z 1 [Note] A temporary password is generated for root@localhost: Nkw6Uma<!p-q
7、修改密碼
[root@dabiaoge yum.repos.d]# mysqladmin -uroot -p'Nkw6Uma<!p-q' password 9qlHZ%cymysqladmin: [Warning] Using a password on the command line interface can be insecure.Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.//祕鑰要符合複雜性要求,不能小於8位