yum search libaio # 检索相关信息
yum install libaio # 安装依赖包
yum list installed | grep mysql
yum -y remove mysql-libs.x86_64 # 移除依赖包mysql-libs.x86_64
yum -y install wget #下载命令
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm #下载mysql源安装包
yum localinstall mysql57-community-release-el7-8.noarch.rpm #安装mysql源
yum repolist enabled | grep "mysql.*-community.*" #检查mysql源是否安装成功
vi /etc/yum.repos.d/mysql-community.repo #可以修改vim /etc/yum.repos.d/mysql-community.repo源,改变默认安装的mysql版本。比如要安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可
yum install mysql-community-server #安装MySQL
systemctl start mysqld #启动MySQL服务
systemctl status mysqld #查看MySQL的启动状态
#开机启动
systemctl enable mysqld
systemctl daemon-reload
grep 'temporary password' /var/log/mysqld.log #查询root本地登录密码,复制密码并执行下一步
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Abc123456789!@'; #修改登录密码,
GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' IDENTIFIED BY 'Abc123456789!@' WITH GRANT OPTION; #设置远程登录用户
flush privileges; #刷新
exit
vi /etc/my.cnf #设置编码格式在[mysqld]下添加编码配置
character_set_server=utf8
init_connect='SET NAMES utf8'
esc
:wq!
systemctl restart mysqld #重启mysql
systemctl status mysqld #mysql状态查询
mysql_secure_installation; #mysql安装设置
网友评论