版权声明:本文为博主原创文章,转载需添加原文链接。 https://blog.csdn.net/makenothing/article/details/85179894
主要记录yum源的安装方式
yum源安装方式
- 下载yum源:
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
- 安装yum源:
yum install mysql57-community-release-el7-8.noarch.rpm
- 检查mysql源是否安装成功:
yum repolist enabled | grep "mysql.*-community.*"
- 选择Mysql的版本:修改文件
vim /etc/yum.repos.d/mysql-community.repo
源。例如要安装5.6版本,将5.7的源的enabled = 1修改为enabled = 0。然后再将5.6源的enabled=0改成enabled=1即可。默认5.7 - 安装MySQL:
yum install -y mysql-server
- 启动Mysql:
$ systemctl start mysqld
或者service mysqld start
此处需要输入系统root密码来授权。启动一次后,mysql的root密码会随机生成一个,然后才能修改mysql的root密码。
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
- 修改root登录密码:安装完后密码是随机的,查看随机密码:
grep 'temporary password' /var/log/mysqld.log
$ grep "password" /var/log/mysqld.log
2018-12-21T15:49:59.010099Z 1 [Note] A temporary password is generated for root@localhost: 1X3YQetYYw(5
- 使用随机密码登陆Mysql:
mysql -u root -p -h 127.0.0.1 -P 3306
,如果不修改密码,不能进行任何操作。必须修改的 。 - 修改密码:
alter user 'root'@'localhost' identified by '新密码';
- 最后记得刷新权限;
flush privileges