最近阿里云过期了,续费太贵就重新买了一个,买完想着老是自己手动装环境啥的太麻烦了,要不也搞个宝塔面板吧,这样后面安装啥的不都很方便了吗?说搞就搞,尼玛才装好试试数据库能不能连接上,沃日并不能;在宝塔中修改了配置文件中的密码,重启后还是不能连上;一直报这个错:”Access denied for user ‘root’@‘localhost’(using password: YES)” ,那怎么办继续解决呗。然后又鼓捣半天总算是搞定了;
mysql -u root; use mysql; update user set authentication_string=password('xxx') where user='root'; # 或者 update user set password=password( 'xxx' ) where User= "root" and Host= "localhost"; FLUSH PRIVILEGES;
重启mysql
1 2 3
service mysqld start; mysql -u root -p; #输入刚修改的密码,验证下是否可以连接
配置远程连接
1 2 3 4 5 6
GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION; FLUSH PRIVILEGES; quit #退出 systemctl restart mysqld #重启mysql firewall-cmd --zone=public --add-port=3306/tcp --permanent #开放3306端口 systemctl restart firewalld.service # 重启防火墙