Linux | 一文搞定Centos下安装mysql及神器mycli

前言

一、下载mysql

1、卸载原Linux中的mysql

# 查看Linux原来的Mysql
rpm -qa | grep -i mysql

# 卸载原来的Mysql
rpm -e 文件名 --nodeps

2、安装

# 下载地址
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

# 使用rpm安装
rpm -ivh mysql80-community-release-el7-3.noarch.rpm

# 更新数据
yum makecache

在这里插入图片描述

在这里插入图片描述

# 查看下载安装服务端
yum list | grep mysql-community-server.x86_64

# 安装,过程输入俩次y
yum install mysql-community-server.x86_64

# 切换到mysql目录
cd /var/lib/mysql

# 尝试启动mysql
systemctl start mysqld

# 查看进程是否有mysql
ps aux | grep mysqld

# 获取密码
grep 'password' /var/log/mysqld.log

在这里插入图片描述

3、版本修改

# 将8.0的enbale改成0,将5.7的enable改成1
vim /etc/yum.repos.d/mysql-community.repo

# 修改后安装
yum install mysql-community-server

4、远程连接

# 登录mysql
mysql -u root -p

# 使用mysql
use mysql

# 设置权限
可使用
GRANT ALL PRIVILEGES on *.* to '用户名'@'主机' IDENTIFIED BY "你的密码" WITH GRANT OPTION;
或者
update user set host='%' where user='root'; 

# 执行生效
flush privileges;

5、修改密码

# 登录mysql
mysql -u root -p

# 使用mysql
use mysql

# 修改密码
update user set authentication_string=password('你的密码') where user='root';

# 执行生效
flush privileges;

二、安装mysql神器mycli

自动完成语法高亮功能

下载安装epel源:
wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/epel//epel-release-latest-7.noarch.rpm -O /tmp/epel-release-latest-7.noarch.rpm

# 安装
yum localinstall -y /tmp/epel-release-latest-7.noarch.rpm

# 安装pip
yum install -y python-pip

# 安装mycli
pip install mycli

# 配置换行
vim ~/.myclirc` 将multi_line改成True

#删除历史记录 
rm -rf .mycli-history
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jxiepc

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值