新装了一台centos6.5的服务器,安装mysql,这里使用了mysql的官方yum源,官方文档?https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/ ,一些看都不懂英文文档的小伙伴可以看一下下面的安装步骤:
1.下载rpm包,并安装RPM源:
wget http://dev.mysql.com/get/mysql57-community-release-el6-8.noarch.rpm
rpm -Uvh mysql57-community-release-el6-n.noarch.rpm
创建mysql的yum源,vim /etc/yum.repos.d/mysql-community.repo
, 填入内容如下,我们这里安装的是5.7的版本mysql 5.7版本:
[mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
mysql5.6版本:
# 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=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
2.生效mysql源:
yum repolist enabled | grep mysql
3.yum安装mysql:
yum install mysql-community-server
4.启动mysql服务:
service mysqld start
5.查看mysql的root临时密码:
grep 'temporary password' /var/log/mysqld.log
6.重设mysql的root密码,这里键入完成后需要输入第5步中显示出来的密码:
mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';