1.卸载
可以通过whereis mysql来查看
rm -rf /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
rm -rf /etc/my.cnf
查看是否还有mysql软件: rpm -qa|grep mysql
rpm -qa | grep -i mysql //如果存在的话,继续删除
2安装
-
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
-
百度网盘链接https://pan.baidu.com/s/1ZlSTeNFIfWgfP4ZkQXKdWA
提取码:xq6v -
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
-
yum install -y mysql-server //yum安装
-
systemctl start mysqld //启动mysql
-
cat /var/log/mysqld.log | grep -E “root@localhost” //查看初始密码
-
mysql -u root -p //进入mysql,输入密码
-
set global validate_password_policy=0;//设置全局验证密码策略
-
set global validate_password_length=1;//设置全局验证密码长度
-
set password=password(‘Hangdong@3008’); //设置密码
-
grant all on . to admin@"%" identified by “password”; //授权
-
flush privileges; //更新权限;
-
显示所有数据库show databases;.
-
选择数据库:use 数据库名;
-
显示数据库中的表show tables;
-
显示数据表的结构describe 表名;
显示表中记录SELECT * FROM 表名;
建库create databse 库名;
执行.sql文件 source /xxx.sql;