Ubuntu LTS MySQL 安裝教學
為甚麼要談安裝Ubuntu LTS MySQL
最開始接觸Linux的時候, 在Ubuntu 上安裝MySQL曾經預到問題就是使用”mysql_secure_installation”的時候, 一直卡在下面這句
Enter password for user root:
爬了不少文章後, 最後發現要首先把碼更改一次, 而且要使用”mysql_native_password”, 希望這篇文章可以幫助也是剛接觸Linux的大家, 以下是教學 橙色字代表系統顯示的信息
, 黑色字則代表需要輸入的命令
更新及安裝MySQL Server
sudo apt update
sudo apt upgrade
sudo apt install mysql-server -y
檢查MySQL是否運行, 如沒有則啟動MySQL
service mysql status
service mysql start
安裝mysql_secure_installation
先更改root密碼
sudo mysql
把”your_password”換做自己的密碼
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_passsword';
exit;
mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
輸入你的密碼
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No:
y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
1
(中等比較方便)
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) :
n
(不更改密碼)
... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) :
y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) :
y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) :
y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) :
y
Success.
All done!
-完-