sudo apt install mariadb-server
sudo systemctl status mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation
sudo mysql -u root mysql
UPDATE user SET PASSWORD=PASSWORD(‘新密码’) where USER=‘root’;
sudo -u root -p:
show databases;
1.使用Linux root登录,然后执行mysql -uroot
2.顺利登录后,切换到数据库mysql:use mysql;
3.查看user表中,账号root的plugin,发现我的安装后默认内容为:unix_socket
4.更改plugin内容:update user set plugin=‘mysql_native_password’ where user=‘root’;
5.执行:flush privileges;
6.重启数据库:systemctl restart mysql
// 切换到root用户, 无需密码进入Mysql
update mysql.user set plugin=‘mysql_native_password’ where user=‘root’;
update mysql.user set password=password(“您的密码”) where user=‘root’;
FLUSH PRIVILEGES;