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

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