1. 查看系统是否已经有mysql安装
rpm -qa | grep mysql
说明没有安装
2. 下载mysql的yum源-----(一定要保证有网络)
Note:这个rmp地址是官网上面找准版本后的rmp的地址:
如下界面上有:
3. 安装mysql的yum源,两种方式安装,也可以用yum命令安装
比如:yum -y install mysql80-community-release-el7-1.noarch.rpm
4. 安装Mysql服务器
yum install mysql-community-server 安装过程中会问yes吗,选yes。
出现如下算完成安装啦:
5. 安装mysql后需要重启mysql
[root@localhost ~]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
6. 初次登陆和随机密码查看
- 刚开始安装的mysql会产生一个随机密码,我们需要找到它,我们可以通过grep命令查找随机root密码。并用它进行登陆来修改密码:
[root@localhost ~]# grep "password" /var/log/mysqld.log
2018-08-01T06:15:38.658556Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 7*nv9jSkw=pw
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 9
Server version: 8.0.12
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
- owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>
7. 修改密码
登陆Mysql后输入以下进行修改
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Daerdee@112' (密码是Daerdee@112)
8. 退出Mysql,并以新密码登陆就可以正常使用Mysql了。