ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

Linux安装Mysql

2022-04-18 23:01:23  阅读:40  来源: 互联网

标签:rpm Mysql Linux repo yum mysql wget root 安装


1.安装wget

yum install -y wget

2.备份

cd /etc/yum.repos.d/

mv CentOS-Base.repo CentOS-Base.repo_bak

3.更换阿里云yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

4. 清除YUM缓存并建立缓存

yum clean all

yum makecache

5.查询mariadb并卸载

rpm -qa | grep mariadb

rpm -e --nodeps mariadb-libs-5.5.65-1.el7.x86_64(复制当前环境的mysql)

6.下载mysql的repo源并安装rpm包

cd /opt/

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

7. 安装mysql

yum install mysql-server -y

8.授予权限

chown -R root:root /var/lib/mysql

chown root /var/lib/mysql/

9.重启mysql数据库

service mysqld restart

10.登录mysql数据库并授权

mysql -u root -p

use mysql

update user set Password = password('ok') where User='root';

GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "ok";

 

11.使配置生效并退出

flush privileges;

exit

12.安装vim并设置字符集

yum install -y vim

vim /etc/my.cnf

添加

character-set-server=utf8

13.重启mysql

service mysqld restart

14.登录mysql数据库

mysql -uroot -pok

标签:rpm,Mysql,Linux,repo,yum,mysql,wget,root,安装
来源: https://www.cnblogs.com/lyabbk/p/16163275.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有