Linux?安裝?MySQL?8.0?及?配置方法
參考我之前的文章
本文的環(huán)境是unbuntu的分支pop os,操作等同于ubuntu
1、更新源
sudo apt update
2、搜索mysql-server
sudo apt search mysql-server
現(xiàn)在可以確保 我們能正常訪問apt倉庫的mysql-server
3、安裝mysql-server
sudo apt install mysql-server
4、配置mysql-server
sudo mysql_secure_installation
(1)、是否啟用VALIDATE PASSWORD 校驗密碼強度
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
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:
確保MySQL服務(wù)器部署的安全性。
使用一個空密碼連接到MySQL。
VALIDATE PASSWORD COMPONENT可用于測試密碼
并提高安全性。它檢查密碼的強度
并允許用戶只設(shè)置那些足夠安全的密碼。
您想設(shè)置VALIDATE PASSWORD組件嗎?按y|Y表示是,按任何其他鍵表示否。
我們不校驗(如果是自己學(xué)習(xí)使用的話),選擇no
(2)、輸入服務(wù)器密碼
輸入mysql的密碼,正常輸入即可
(密碼一定要記住了,忘了就比較麻煩)
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 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) :
默認(rèn)情況下,MySQL裝有一個匿名用戶。
允許任何人登錄MySQL,而不需要為他們創(chuàng)建一個用戶帳戶。
這僅僅是為了測試,并使安裝更順利一些。
在進(jìn)入生產(chǎn)環(huán)境之前,你應(yīng)該刪除它們。刪除匿名用戶?(按y|Y表示是,按任何其他鍵表示否) 。
我們選擇Y 刪除匿名用戶
(4)、是否允許遠(yuǎn)程登陸
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īng)該只允許root從'localhost'連接。這可以確保有人無法從網(wǎng)絡(luò)上猜出root密碼。
不允許root遠(yuǎn)程登錄?(按y|Y表示是,按任何其他鍵表示否) 。
我們選擇N,允許root遠(yuǎn)程連接
(5)、是否刪除test數(shù)據(jù)庫
Remove test database and access to it? (Press y|Y for Yes, any other key for No) :
刪除test數(shù)據(jù)庫和對它的訪問?(按y|Y表示是,按任何其他鍵表示否) 。
我們選擇N,不刪除test數(shù)據(jù)庫
(6)、重新加載權(quán)限表
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) :
重新加載權(quán)限表將確保到目前為止所有的改變
將立即生效。現(xiàn)在重新加載權(quán)限表?(按y|Y表示是,按任何其他鍵表示否) 。
我們選擇Y 立即生效
至此,配置完成
5、檢查MySQL服務(wù)器狀態(tài)
MySQL服務(wù)器在安裝后自動啟動。您可以使用以下命令檢查MySQL服務(wù)器的狀態(tài):
systemctl status mysql
使用下邊的命令,停止MySQL的運行:
service mysql stop
使用下邊的命令,啟動MySQL server
service mysql start
使用下邊的命令,重啟MySQL server
service mysql restart
6、配置遠(yuǎn)程訪問
Ubuntu下MySQL是只允許本地訪問,使用 數(shù)據(jù)庫圖形化連接 工具是連不上的;
如果你要訪問的話需要進(jìn)行配置
sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf
找到 bind-address 修改值為 0.0.0.0
或者直接注釋這一條
登陸mysql
sudo mysql -u root -p
創(chuàng)建賬戶允許
create user 'root'@'%' identified by '你的密碼';
給這個用戶授予權(quán)限
grant all privileges on *.* to 'root'@'%' with grant option;
刷新權(quán)限
flush privileges;
退出mysql
quit
重啟MySQL server
service mysql restart
7、禁止開機自啟
sudo systemctl disable mysql
8、登陸MySQL 登陸
sudo mysql -uroot -p
查詢數(shù)據(jù)庫
show databases;
到此這篇關(guān)于Linux 安裝 MySQL 8.0 及 配置的文章就介紹到這了,更多相關(guān)MySQL 8.0 安裝配置內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
mysql5.5與mysq 5.6中禁用innodb引擎的方法
這篇文章主要介紹了mysql5.5中禁用innodb引擎的方法,需要的朋友可以參考下2014-04-04Windows系統(tǒng)下MySQL添加到系統(tǒng)服務(wù)方法(mysql解壓版)
這篇文章主要介紹了Windows系統(tǒng)下MySQL添加到系統(tǒng)服務(wù)方法,主要針對mysql解壓版,感興趣的朋友參考下吧2016-05-05mysql中insert?into...select語句優(yōu)化方式
這篇文章主要介紹了mysql中insert?into...select語句優(yōu)化方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教<BR>2024-04-04MySQL通過存儲過程來添加和刪除分區(qū)的過程(List分區(qū))
這篇文章主要介紹了MySQL-通過存儲過程來添加和刪除分區(qū)(List分區(qū)),本文通過創(chuàng)建存儲過程來添加和刪除分區(qū),可以避免在分區(qū)存在時添加分區(qū)報錯,或者分區(qū)不存在時刪除分區(qū)報錯的問題,需要的朋友可以參考下2023-09-09