Linux mysql 8.x设置简单密码及其卸载
程序员文章站
2022-05-27 13:33:24
...
初次安装查看密码并设置简单密码
#安装mysql
rpm -ivh mysql-community-common-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm
# 启动mysql
systemctl start mysqld
#如果mysql -uroot -p 有反应就不用上面的
#要mysql启动之后才可以查看mysql 初始随机密码
cat /var/log/mysqld.log | grep password
#可以看到
2020-04-01T00:08:43.635563Z 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: b.D>qKr4JR<k
# b.D>qKr4JR<k 就是新密码
#然后登录mysql
root -uroot -p
#输入密码: 注意这里粘贴是无效的
#1.先设置一个普通密码
set global validate_password.policy=0;
set global validate_password.length=1;
alter user 'root'@'localhost' identified by 'a123456';
#2.密码修改后,可用命令查看 validate_password 密码验证插件是否安装。
SHOW VARIABLES LIKE 'validate_password%';
#3.重新设置密码: ALTER USER 'root'@'localhost' IDENTIFIED BY '你的密码'
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
安装报错解决
报错1
error: Failed dependencies: /usr/bin/perl is needed by
mysql-community-server-8.0.11-1.el7.x86_64 perl(Getopt::Long) is
needed by mysql-community-server-8.0.11-1.el7.x86_64 perl(strict)
#解决1
yum install perl
报错2
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-8.0.11-1.el7.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-8.0.11-1.el7.x86_64
#解决2
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm
rpm -ivh http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm
报错3
error: Failed dependencies:
mariadb-libs is obsoleted by mysql-community-libs-8.0.11-1.el7.x86_64
#解决3
#如上的报错,由于centos 7默认是mariadb数据库,再去安装mysql之前要先下载mariadb或者卸载
#查看mariadb
rpm -qa | grep mariadb
#安装 mariadb-libs-5.5.52-1.el7.x86_64
rpm -e mariadb-libs-5.5.52-1.el7.x86_64
#报错
error: Failed dependencies:
libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
#由于存在依赖关系,强制卸载
rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
#然后继续输入按照安装MySQL命令即可
#报错4
error: Failed dependencies:
net-tools is needed by mysql-community-server-8.0.11-1.el7.x86_64
#解决4
#方法一(无网):后面加上 --force --nodeps
rpm -ivh mysql-community-server-5.7.19-1.el7.x86_64.rpm --force --nodeps
#方法二(有网):yum install net-tools
yum install net-tools
#报错5
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
完全卸载mysql
#安装之前需要检测系统是否有安装mysql
rpm -qa | grep mysql
#查看mysql所有的nodes
# 然后依次卸载
rpm -e --nodeps mysql-community-libs-8.0.11-1.el7.x86_64
rpm -e --nodeps mysql-community-server-8.0.11-1.el7.x86_64
rpm -e --nodeps mysql-community-common-8.0.11-1.el7.x86_64
rpm -e --nodeps mysql-community-client-8.0.11-1.el7.x86_64
rm -rf /etc/my.cnf
find / -name mysql.*
rm mysql.sock
上一篇: my.cnf配置文件详解
下一篇: Jenkins 修改时区