华为云CentOS8安装MYSQL

 

yum install -y mysql-server
mysql启动

systemctl start mysqld.service
systemctl enable mysqld.service
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --reload
登入mysql,没有密码回车就行

mysql -uroot -p //随机密码登录
设置root密码

use mysql;

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root123456!';
退出重登

#退出
exit
#重登
mysql -uroot -p
设置远程访问

use mysql;

update user set host = '%' where user = 'root';

FLUSH PRIVILEGES;

 

再次登录,输入密码

mysql -u root -p

------------------------------------------------------------------

centos mysql8.0降级安装Mysql5.7

1、删除mysql8.0

yum remove mysql

2、删除共享Lib库,这一步很关键,一定要这里执行呀

rm -R /var/lib/mysql

3、安装mysql5.7

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server

--------------------------------------------------------------------

重置密码遇到ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
passwor:yes)问题

1.重置密码的第一步就是跳过MySQL的密码认证过程,方法如下:
#vim /etc/my.cnf(注:windows下修改的是my.ini)

在[mysqld]后面任意一行添加“skip-grant-tables”用来跳过密码验证的过程
保存文档并退出

2.systemctl restart mysqld

3.进入到终端当中,敲入 mysql -u root -p 命令然后回车,当需要输入密码时,直接按enter键,便可
以不用密码登录到数据库当中
mysql> update mysql.user set authentication_string=password('新密码') where user='root';
mysql> flush privileges;
mysql> quit

4.#vim /etc/my.cnf(注:windows下修改的是my.ini)
删除“skip-grant-tables”

5.systemctl restart mysqld

 

密码降级

set global validate_password_policy=0;

set global validate_password_length=1;

alter user 'root'@'localhost' identified by '123456';

posted @ 2021-07-06 07:46  jamesben  阅读(344)  评论(0编辑  收藏  举报