现象:
在centOS7中启动MySQL数据库提示:
Failed to start mysqld.service: Unit not found
明明已经安装了,为什么提示不存在呢?
原因:
在CentOS7中已经不在支持mysql,就算你已经安装了,CentOS7还是表示很嫌弃。
解决方案:
安装mysql另起炉灶的开源版本:MariaDB
MariaDB如同 MySQL 的影子版本,MariaDB数据库是 MySQL 的一个分支版本(branch),而不是衍生版本(folk),提供的功能可和 MySQL 完全兼容。
1、首先需要安装mariadb-server
yum install -y mariadb-server
2、启动服务
systemctl start mariadb.service
3、添加到开机启动
systemctl enable mariadb.service
4、进行一些安全设置,以及修改数据库管理员密码
mysql_secure_installation
5、mysql给root开启远程访问权限
use mysql;
select User,authentication_string,Host from user;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
flush privileges;
exit;
可能出现的问题:
MariadDB 启动时报错
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
解决方法:
[root@cdh01 mysql]# cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
[root@cdh01 mysql]# systemctl start mariadb.service