相关链接:
在 CentOS 1804 中 使用 yum 安装 MySQL 5.7 最新版
在 CentOS 1804 中 安装 MySQL 5.7.20 (或任意MySQL版本)
在不打开 MySQL 3306 端口的情况下,使用 Navicat 进项远程连接(使用22端口)
在 Ubuntu 中安装 MySQL5.7.20(任意版本)
CentOS 6/7 安装 MySQL 8.0.11 (或任意版)
MySQL 5.7 最新版 使用 yum 安装 MySQL NDB Cluster 7.5 最新版 集群
MySQL 集群 MySQL NDB Cluster 7.5.** 与 MySQL 5.7.** 对应版本说明
MySQL 集群 MySQL NDB Cluster 7.6.** 与 MySQL 5.7.** 对应版本说明
MySQL 5.7.20 (或指定版本) 与 MySQL NDB Cluster 7.6.4 (或指定版本) 集群
Windows 安装 MySQL 5.7.20 教程(及常见问题解决)
MySQL 5.7.20 (或任意版本) 的 Windows 版 安装程序 (msi) 下载
- 下载MySQL5.7.20(或任意版,笔者以5.7.20为例,截止笔者发稿,最新版为5.7.23)相关组件:
下载网址:http://repo.mysql.com/yum/
这里包含了MySQL的所有版本,如图所示:
本人以5.7为例,打开mysql-5.7-community,如图所示:
打开el(el是Red Hat,CentOS和CloudLinux的缩写),如图所示:
选择7(代表CentOS 7等),如图所示:
选择x86_x64,如图所示:
在CentOS 1804 中安装MySQL 5.7.20需要的组件为(此顺序也是安装顺序):
mysql-community-common-5.7.20-1.el7.x86_64.rpm
mysql-community-libs-5.7.20-1.el7.x86_64.rpm
mysql-community-client-5.7.20-1.el7.x86_64.rpm
mysql-community-server-5.7.20-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm(选装)wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.20-1.el7.x86_64.rpm wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.20-1.el7.x86_64.rpm wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.20-1.el7.x86_64.rpm wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.20-1.el7.x86_64.rpm wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm
- 将下载好的组件上传到CentOS中,如图所示:
- 首先卸载maria:
查看是否安装了maria:
卸载maria:[root@CSDNBlogs ~]# rpm -qa | grep maria mariadb-libs-5.5.60-1.el7_5.x86_64
[root@CSDNBlogs ~]# yum -y remove mariadb-libs-5.5.60-1.el7_5.x86_64
- 进入以上传文件目录:
[root@CSDNBlogs ~]# cd /usr/java/doc/ [root@CSDNBlogs doc]# ls mysql-community-client-5.7.20-1.el7.x86_64.rpm mysql-community-libs-5.7.20-1.el7.x86_64.rpm mysql-community-common-5.7.20-1.el7.x86_64.rpm mysql-community-server-5.7.20-1.el7.x86_64.rpm
- 安装mysql-community-common*:
安装mysql-community-libs*:
安装mysql-community-client*:
安装mysql-community-server*:yum -y install mysql-community-common* yum -y install mysql-community-libs* yum -y install mysql-community-client* yum -y install mysql-community-server*
- 至此,已经安装完成,下面进行相关配置。
- 开启MySQL数据库:
[root@CSDNBlogs doc]# systemctl start mysqld
- 开启MySQL的开机自启:
[root@CSDNBlogs doc]# systemctl enable mysqld
- 重新载入:
[root@CSDNBlogs doc]# systemctl daemon-reload
- 查看MySQL预设密码:
使用命令(优先选择):
或者使用:[root@CSDNBlogs doc]# grep 'temporary password' /var/log/mysqld.log 2018-09-21T02:47:01.590809Z 1 [Note] A temporary password is generated for root@localhost: 3:gd&v_2hw(H
大约在第10行左右(每行开始为时间),显示如下:[root@CSDNBlogs doc]# less /var/log/mysqld.log
root@localhost后面就是预设密码。2018-09-21T02:47:01.590809Z 1 [Note] A temporary password is generated for root@localhost: 3:gd&v_2hw(H
- 登录MySQL数据库:
上面第5行显示为Server version: 5.7.20,是MySQL的版本(在这里吐槽一下,网上有很多方法查看MySQL安装版本,那些人想必没有仔细看过登录时的信息,说多了,言归正传)。[root@CSDNBlogs doc]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.20 Copyright (c) 2000, 2017, 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>
- 初次登录,修改数据库密码:
推荐:
或:mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; Query OK, 0 rows affected (0.00 sec)
设置密码要符合规范(大小写,数字,特殊字符),不认设置不成功,如果想设置简单的密码,请阅读本文开头或结束的其他文章。mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass4!'); Query OK, 0 rows affected, 1 warning (0.00 sec)
-
授权远程访问数据库:
此方法不推荐,有其他更好的方式,请阅读本文开头或结束的其他文章。mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Ass-Ubc+457'; Query OK, 0 rows affected, 1 warning (0.00 sec)
本文已完结。
相关链接:
在 CentOS 1804 中 使用 yum 安装 MySQL 5.7 最新版
在 CentOS 1804 中 安装 MySQL 5.7.20 (或任意MySQL版本)
在不打开 MySQL 3306 端口的情况下,使用 Navicat 进项远程连接(使用22端口)
在 Ubuntu 中安装 MySQL5.7.20(任意版本)
CentOS 6/7 安装 MySQL 8.0.11 (或任意版)
MySQL 5.7 最新版 使用 yum 安装 MySQL NDB Cluster 7.5 最新版 集群
MySQL 集群 MySQL NDB Cluster 7.5.** 与 MySQL 5.7.** 对应版本说明
MySQL 集群 MySQL NDB Cluster 7.6.** 与 MySQL 5.7.** 对应版本说明
MySQL 5.7.20 (或指定版本) 与 MySQL NDB Cluster 7.6.4 (或指定版本) 集群