1 下载安装包
访问https://dev.mysql.com/将网页划到最下面,点击下载MySQL社区安装包
按照如下图片框选的进行下载
2 解压上传
下载完了之后使用WinRAR软件在Windows电脑上解压,选择如下包使用ftp工具上传至Linux机器最大目录下。
3 安装前检查
检查是否已经安装了旧版的MySQL和mariadb
rpm -qa | grep mysqlrpm -qa | grep mariadb
如果有安装那就卸载,卸载命令如下:
rpm -e --nodeps mysql包名rpm -e --nodeps mariadb包名
4 安装
在安装包存储目录分别按照顺序执行如下命令:
rpm -ivh mysql-community-common-8.0.32-1.el7.x86_64.rpm
2、rpm -ivh mysql-community-client-plugins-8.0.32-1.el7.x86_64.rpm
3、rpm -ivh mysql-community-libs-8.0.32-1.el7.x86_64.rpm
注意:如果安装libs时提示error
则先执行:yum remove -y mysql-libs
再执行:rpm -ivh mysql-community-libs-8.0.32-1.el7.x86_64.rpm
4、rpm -ivh mysql-community-client-8.0.32-1.el7.x86_64.rpm
5、rpm -ivh mysql-community-server-8.0.32-1.el7.x86_64.rpm
注意:如果安装server时提示error
则先执行:rpm -ivh mysql-community-server-8.0.32-1.el7.x86_64.rpm --nodeps --force
再执行:rpm -ivh mysql-community-server-8.0.32-1.el7.x86_64.rpm
5 启动配置MySQL
5.1 启动MySQL
systemctl start mysqld
5.2 查看版本验证
mysql --version
5.3 初始化
mysqld --initialize --user=mysql
5.4 查看初始密码
cat /var/log/mysqld.log | grep password
5.5 登陆数据库
mysql -u root -p 查看的密码
5.6 修改默认密码
alter user 'root'@'localhost' identified by '你的密码';
5.7 设置远程访问
use mysql;update user set host = '%' where user ='root';flush privileges;
来源地址:https://blog.csdn.net/qq_43003203/article/details/130916515