1.安装
这里我们使用apt方式直接安装
sudo apt-get
install -y mysql-server mysql-client
2.设置密码
打开终端输入以下命令:
sudo mysql -uroot -p
要求输入密码是直接按回车可以直接进入(sudo必须加,不加进不去)。
如下图:
成功进入命令行模式以后依次执行下面命令设置密码
update mysql.
user set plugin
="mysql_native_password"
where user="root";grant all on *.
* to root@"localhost";update mysql.
user set authentication_string
=password(
'这里是你的密码')
where user='root'and Host
= 'localhost';flush privileges;
执行情况如下图:
3.测试
然后测试root账户能否使用密码正常登录,输入以下命令
mysql
-uroot
-p
再输入密码即可登录。
安装成功!
转载于:https://www.cnblogs.com/Zlcode/p/11475298.html