很多人對本博客的方法提出了質(zhì)疑,在此我解釋一下:
由于MySQL在CentOS7中收費了,所以已經(jīng)不支持MySQL了,取而代之在CentOS7內(nèi)部集成了mariadb,而安裝MySQL的話會和MariaDB的文件沖突。所以本文建議直接安裝mariadb。
具體討論的詳情大家可以參考知乎討論:https://www.zhihu.com/question/41832866,本文不再贅述。
# 輸入命令
systemctl start mysql.service
# 要啟動MySQL數(shù)據(jù)庫是卻是這樣的提示
Failed to start mysqld.service: Unit not found
解決方法如下:
解決方法如下:
# 首先需要安裝mariadb-server
yum install -y mariadb-server
# 啟動服務(wù)
systemctl start mariadb.service
# 添加到開機啟動
systemctl enable mariadb.service
# 進行一些安全設(shè)置,以及修改數(shù)據(jù)庫管理員密碼
[zhaojq@localhost]$ mysql_secure_installation

image-20211124085610559.png
mysql給root開啟遠程訪問權(quán)限
use mysql;
select User,authentication_string,Host from user;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
flush privileges;