一、安装数据库
1.重定向生成配置文件
cat >/etc/yum.repos.d/mysql.repo <<EOF
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/
enabled=1
gpgcheck=0
EOF
2.yum安装
yum -y install mysql-community-server
3.开启数据库
systemctl start mysqld
4.获取临时密码
grep -i "password" /var/log/mysqld.log
5.修改mysql密码
set global validate_password_policy=0;#长度无要求
set global validate_password_length=1;#复杂性无要求
alter user root@'localhost' identified by 'abc123';
6.退出数据库
quit
7.用新密码登录
mysql -u root -pabc123
二、安装mycli插件
1.yum安装Python
安装mycli,需要用Python安装
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
2.准备安装包
make /data
###创建data
cd /data
去data目录下安装
3.解压缩包
tar zxvf Python-3.7.7_.tgz
4.切到Python下
cd Python-3.7.7/
5.编译
./configure --prefix=/usr/local/Python-3.7.7/
6.如果报错
如果报错:
configure: error: in `/data/Python-3.7.7': configure: error: no acceptable C
yum -y install gcc####解决依赖环境问题
然后再./configure,执行一下上一条命令就好了
7.将高级语言翻译成二进制
make
8.将文件复制到硬盘
make install
9.优化路径
ln -s /usr/local/Python-3.7.7/bin/python3.7 /usr/bin/python37
ln -s /usr/local/Python-3.7.7/bin/pip3.7 /usr/bin/pip37
10.安装mycli
pip37 install mycli -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
11.路径优化
ln -s /usr/local/Python-3.7.7/bin/mycli /usr/bin/mycli
12.用mycli登录数据库
mycli -u root -p 123123
三、Mycli作用
方便与初学者操作
1. 命令可以补全选择 (类似于输入法功能)
2. 可以上下回看命令