修改root本地登录密码
修改root默认的密码(方法一)
1.启动mysql之后systemctl start mysqld.service
2.修改mysql的配置文件 vi /etc/my.cnf
找到[mysqld]
skip-grant-tables
skip-networking
3.重启mysql systemctl restart mysqld.service
4.重新登陆mysql 就会跳过密码
mysql -uroot -p
5.设置新的密码
update mysql.user set authentication_string=password('123456') where user='root';
6.然后刷新保存
flush privileges;
7.退出mysql exit
再进入vi /etc/my.cnf skip-grant-tables skip-networking 删除
8.重启mysql服务器 systemctl restart mysqld.service
9.再登陆就输入新的密码即可mysql -uroot -p
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY “”
MyNewPwd123!@# 密码需要有大写字母 数字 和特殊字符
修改root默认的密码(方法二)
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
shell> grep 'temporary password' /var/log/mysqld.log
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
或者
mysql> set password for 'root'@'localhost'=password('MyNewPass4!');
记得加grant all on *.* to 'root'@'%' identified by 'MyNewPass4!'; 才可以mysqlFont远程连接
3167错误
mysql> show variables like '%show_compatibility_56%';
mysql> set global show_compatibility_56=on;
1055错误
vim /etc/my.cnf 下面添加
sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
添加3306端口(已经添加请忽略)
firewall-cmd --zone=public --add-port=3306/tcp --permanent
重新启动防火墙
systemctl restart firewalld.service
MySQL远程连接:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;