0
点赞
收藏
分享

微信扫一扫

centos查看mysql默认密码和修改密码

三分梦_0bc3 2023-09-02 阅读 9

1、查看mysql默认密码:

grep ‘temporary password’ /var/log/mysqld.log

centos查看mysql默认密码和修改密码_vim


root@localhost: b_1sZou9FZrt b_1sZou9FZrt就是

2、修改mysql密码:

ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘new password’;‘new password’替换成你要设置的密码,注意:密码设置必须要大小写字母数字和特殊符号(,/’;:等),不然不能配置成功

3、开启mysql的远程访问

开启所有的,用%代替IP

grant all privileges on . to ‘root’@‘192.168.0.1’ identified by ‘password’ with grant option;

password:为mysql设置的密码。

4、退出mysql:

mysql> exit

5、为firewalld添加开放端口

firewall-cmd --znotallow=public --add-port=3306/tcp --permanent

firewall-cmd --znotallow=public --add-port=8080/tcp --permanent

firewall-cmd --reload

centos查看mysql默认密码和修改密码_mysql_02


6、更改mysql的字符集
登录mysql: mysql -uroot -p
查看字符集:
mysql> status

centos查看mysql默认密码和修改密码_mysql_03

vim etc/my.cnf文件:

centos查看mysql默认密码和修改密码_vim_04


[client] 首行

default-character-set=utf8 第二行

character-set-server=utf8 倒数第二行

collation-server=utf8_general_ci 倒数第一行

增加这几行到相应位置;

然后保存并退出:

重启mysql:

service mysqld restart

举报

相关推荐

0 条评论