一、安装mysql
1、查看是否安装过mysql
[hadoop@h3 modules]$rpm -qa | grep -i mysql
此种情况表示安装过,卸载如下:
[hadoop@h3 modules]$ sudo yum remove mysql-community-libs-5.7.23-1.el7.x86_64
[hadoop@h3 modules]$ sudo yum remove mysql57-community-release-el7-8.noarch
[hadoop@h3 modules]$ sudo yum remove mysql-community-common-5.7.23-1.el7.x86_64
[hadoop@h3 modules]$ whereis mysql
mysql: /usr/share/mysql
[hadoop@h3 modules]$ rm -rf /usr/share/mysql
[hadoop@h3 modules]$ whereis mysql
mysql:[hadoop@h3 modules]$
再次查看有无安装:
结果显示表示并未安装过。
2、配置yum源
下载mysql:
[hadoop@h3 modules]$ wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum安装mysql:
[hadoop@h3 modules]$ sudo yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
3、安装mysql
[hadoop@h3 modules]$ sudo yum install mysql-community-server
4、启动
systemctl start mysqld或service mysqld start或者/etc/init.d/mysqld start
查看启动状态:
systemctl status mysqld
5、设置开机启动
systemctl enable mysqld
systemctl daemon-reload
6、修改root默认密码
mysql安装完成之后,在/var/log/mysqld.log文件中会生