Linux (Debian) 安装MySQL 后如何获取登录密码
<h3 id="树莓派安装mysql后获取登录密码">树莓派安装MySQL后获取登录密码</h3><p>树莓派基于Debian系统。</p>
<p>成功安装MySQL后</p>
<pre><code>su root
vim /etc/mysql/debian.cnf
</code></pre>
<p>其中 user 和 password 就是你用于登录mysql的默认账户和密码。</p>
<pre><code>mysql -udebian-sys-maint -p
//键入passwd
</code></pre>
<p>就可以成功进入MySQL服务界面,更新默认账户密码设置。</p>
<pre><code>show databases; // 1.展示所有数据库
use mysql; //2.选择mysql数据库
// 3.更新root密码(5.7 之前的mysql)
update mysql.user set password=password('123456') where user='newuser' and host='localhost';
//3.更新root密码(5.7 之后的mysql) 这两个命令可以都尝试下
update mysql.user set authentication_string=password('123456') where user='newuser' and host='localhost';
//4.权限刷新
flush privileges;
</code></pre>
<p>之后就可以用我们最熟悉的<code>mysql-uroot -p</code>来登录了。</p><br><br>
来源:https://www.cnblogs.com/masterchd/p/12827729.html
頁:
[1]