首先执行命令
sudo apt install mariadb-server

之后可以通过 systemctl 命令控制数据库的启动和停止
systemctl start mariadb
systemctl restart mariadb
systemctl stop mariadb
systemctl reload mariadb

Securing MariaDB Server in Debian 10
使用 sudo mysql_secure_installation
重置 root 密码。

或者用以下方式:
- Login first with MySQL Command shell.
sudo mysql -u root -p
- Change the password as strong:
ALTER USER 'root'@'localhost' Identified by 'new-password';
- Execute the flush privileges:
FLUSH PRIVILEGES;
这种方式好一些, 不会出现不能访问的错误。
这样以后就可以通过
mysql -u root -p
并输入设置的数据库访问密码登录了。
网友评论