Linux 系统怎么安装 MySQL
2021-12-17 本文已影响0人
孙庚辛
首先执行命令
sudo apt install mariadb-server
![](https://img.haomeiwen.com/i4348380/7aa2a267aa80fb72.png)
之后可以通过 systemctl 命令控制数据库的启动和停止
systemctl start mariadb
systemctl restart mariadb
systemctl stop mariadb
systemctl reload mariadb
![](https://img.haomeiwen.com/i4348380/1efe7de6f5ce1c40.png)
Securing MariaDB Server in Debian 10
使用 sudo mysql_secure_installation
重置 root 密码。
![](https://img.haomeiwen.com/i4348380/6f083663aadbcd4f.png)
或者用以下方式:
- 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
并输入设置的数据库访问密码登录了。