版本以及操作系统:Server version: 5.7.17-0ubuntu0.16.04.1 (Ubuntu-server)
尝试直接apt-get install mysql-server,安装过程中弹出让输入密码的框都直接回车。
安装好之后,输入mysql可以直接登陆数据库,尝试用mysqladmin -u root password "password"``来设置密码,弹出两条警告:
$ mysqladmin -u root password "123"
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
再次尝试登陆,还是可以直接输入mysql登陆(尝试过重启数据库)。
第二次尝试登陆进数据库,使用update mysql.user set authentication_string=PASSWORD('123123') where user='root';设置,然后刷新权限flush privileges;
再次尝试登陆,还是不用输任何密码就可以登陆成功(有重启数据库)
那么,现在问题来了:
我要怎样才能成功的给数据库设个密码呢?(除了在安装时弹出框里输入)
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
试试使用 mysql_secure_installion
你的账号里面应该是有空账号 你并没有删除或者为这个空账号设置密码
delete from mysql.user where user='';flush privileges;
或者
update mysql.user set authentication_string=PASSWORD('123123');flush privileges;