Centos7安装Mysql
找到Red Hat Enterprise Linux 7 / Oracle Linux 7按提示下载,或者抓下下载链接直接在Linux里用wget下载,我抓的url
https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
1. 下载好,安装yum源
[root@localhost home]# yum install mysql80-community-release-el7-3.noarch.rpm
2. 安装MySQL
[root@localhost home]# yum -y install mysql-community-server —nogpgcheck
3. 启动MySQL服务器和MySQL的自动启动
[root@localhost home]# systemctl start mysqld.service [root@localhost home]# systemctl enable mysqld.service
4. 由于MySQL从5.7开始不允许首次安装后使用空密码进行登录!系统会随机生成一个密码以供管理员首次登录使用,这个密码记录在/var/log/mysqld.log文件中,使用下面的命令可以查看此密码:
[root@localhost home]# cat /var/log/mysqld.log | grep ‘A temporary password’
2020-02-18T13:12:38.539528Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: pfl>p>)Ey1pW
5. 使用默认账户登录MySQL
[root@localhost home]# mysql -p Enter password: 由于这里使用随机密码登录所以mysql不能正常使用,需要修改密码,而由于安全机制问题修改复杂密码太麻烦,所以参考链接:《Mysql修改密码》
6. 重新登陆MySQL验证安装情况
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.11 sec)