MySQL安装
Posted 尊宝雷
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL安装相关的知识,希望对你有一定的参考价值。
一、检查当前环境是否安装mysql,如有安装MySQL或者Mariadb,可以卸载;
rpm -qa | grep mysql
pm -qa |grep mariadb
yum remove mariadb-libs-5.5.64-1.el7.x86_64
二、下载并安装
1、国内用户考虑切换yum源为阿里云;
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum update -y
2、下载对应版本的MySQL RPM安装包,下载地址http://mirrors.ustc.edu.cn/mysql-ftp/Downloads
# server包
wget https://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-server-5.7.31-1.el7.x86_64.rpm
# client包
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-client-5.7.31-1.el7.x86_64.rpm
# common包
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-common-5.7.31-1.el7.x86_64.rpm
# lib包
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-libs-5.7.31-1.el7.x86_64.rpm
3、安装依赖包
yum install -y perl libaio net-tools
4、安装对应版本的MySQL(按顺序)
rpm -ivh mysql-community-common-5.7.31-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-5.7.31-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-5.7.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.31-1.el7.x86_64.rpm
5、启动MySQL
systemctl start mysqld.service
systemctl status mysqld.service
6、登陆MySQL更新默认密码,
# 获取默认root密码
cat /var/log/mysqld.log | grep \'password\'
# 登陆mysql,更改默认密码
mysql -u root -p
set password=password(\'xxxxxx\')
# 开启远程连接
use mysql;
update user set Host = \'%\' where Host = \'localhost\' and User=\'root\';
flush privileges;
以上是关于MySQL安装的主要内容,如果未能解决你的问题,请参考以下文章
连接MySQL出现错误:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)(代码片段
使用 json rereiver php mysql 在片段中填充列表视图
在Tomcat的安装目录下conf目录下的server.xml文件中增加一个xml代码片段,该代码片段中每个属性的含义与用途
关于mysql驱动版本报错解决,Cause: com.mysql.jdbc.exceptions.jdbc4Unknown system variable ‘query_cache_size(代码片段