主機系統:ubuntu18.10
安裝MySQL版本:MySQL-5.7.25
ubuntu查看系統版本: 命令: sudo lsb_release -a
ubuntu 18.1 安裝 MySQL
目錄
1.更新系統包索引 命令: sudo apt-get update
2.開始安裝mysql 命令: sudo apt-get install mysql-server
4.查看MySQL的狀態 命令 sudo service mysql status
6.重置MySQL密碼 命令:(需進入MySQL)SET PASSWORD FOR root@'localhost' = PASSWORD('newpassword');
-
1.更新系統包索引 命令: sudo apt-get update
-
2.開始安裝mysql 命令: sudo apt-get install mysql-server
注意: 上面命令執行後, 會出現存儲空間使用允許的詢問,輸入 Y 就可以繼續安裝了。
#1
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N (我的選項)
#2
Please set the password for root here...
New password: (輸入密碼)
Re-enter new password: (重複輸入)
#3
By default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them...
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y (我的選項) # 若對mysql 不熟悉,建議選N(這樣只要在命令行輸入MySQL,就可以進入MySQL了。)
#4
Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess atthe root password from the network...
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N (我的選項) # 我需要遠程使用root目錄,建議選Y(基於安全)。
#5
By default, MySQL comes with a database named 'test' thatanyone can access...
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (我的選項)
#6
Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (我的選項)
-
3.配置完成
-
4.查看MySQL的狀態 命令 sudo service mysql status
active(running)就是正常運行的
-
5.登錄MySQL 命令:mysql -u root -p
再輸入密碼就好了(輸入密碼屏幕是不會顯示輸入字符的)
-
6.重置MySQL密碼 命令:(需進入MySQL)SET PASSWORD FOR root@'localhost' = PASSWORD('newpassword');