在Ubuntu上配置MySQL的步驟如下:
sudo apt update
sudo apt install mysql-server
在安裝過程中,系統會提示您設置MySQL的root用戶密碼,請確保選擇一個安全的密碼并妥善保存。
sudo systemctl start mysql
sudo systemctl enable mysql
sudo systemctl status mysql
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
bind_address:允許遠程訪問(如果需要):bind_address = 0.0.0.0
max_connections:最大連接數:max_connections = 200
保存并關閉文件。
重啟MySQL服務以使更改生效:
sudo systemctl restart mysql
sudo mysql -u root -p
輸入之前設置的root密碼登錄。
sudo mysql_secure_installation
按照提示進行配置,包括設置root密碼、刪除匿名用戶、禁止遠程root登錄等。
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
通過以上步驟,您可以在Ubuntu上成功安裝和配置MySQL服務器,并確保其安全性。