對于Linux 用戶,MySQL 是免費的關系數據庫管理系統,因此成為Linux 用戶最常用的數據庫之一。在本文中,我們將看到如何在Linux 服務器上安裝和配置 MySQL。
1.安裝MySQL
sudo apt-get update sudo apt-get install mysql-server
2.啟動MySQL
sudo systemctl start mysql
3.設置MySQL自動啟動
sudo systemctl enable mysql
4.設置MySQL安全
sudo mysql_secure_installation
5.登錄MySQL
mysql -u root -p
6.創建新用戶
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
7.授權用戶
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
8.刷新MySQL權限
FLUSH PRIVILEGES;
完整安裝過程:
sudo apt-get update sudo apt-get install mysql-server sudo systemctl start mysql sudo systemctl enable mysql sudo mysql_secure_installation mysql -u root -p CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; FLUSH PRIVILEGES;