CentOS6.5安装MySQL5.7
以hadoop用户登录系统,
1.检测系统是否已经安装过mysql或其依赖,若已装过要先将其删除,否则第4步使用yum安装时会报错:
#查看mysql是否安装,如果已经安装需要卸载,如果是
sudo rpm -qa|grep mysql
2、如果存在mysql,依次卸载
sudo yum -y remove mysql-community-server-5.7.23-1.el6.x86_64
sudo yum -y remove mysql-community-libs-5.7.23-1.el6.x86_64
sudo yum -y remove mysql-community-common-5.7.23-1.el6.x86_64
sudo yum -y remove mysql-community-client-5.7.23-1.el6.x86_64
find / -name mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /var/lib/mysql/mysql
sudo rm -rf /usr/share/mysql
3、解压依次安装
tar -xvf mysql-5.7.23-1.el6.x86_64.rpm-bundle.tar
#解压
sudo rpm -ivh mysql-community-common-5.7.23-1.el6.x86_64.rpm
sudo rpm -ivh mysql-community-libs-5.7.23-1.el6.x86_64.rpm
sudo rpm -ivh mysql-community-client-5.7.23-1.el6.x86_64.rpm
sudo rpm -ivh mysql-community-server-5.7.23-1.el6.x86_64.rpm
4、启动服务
sudo service mysqld start #启动mysqld服务
5、修改配置文件无密码登录
sudo vi /etc/my.cnf
在最尾部加上
skip-grant-tables
保存
6、重启mysql服务
sudo service mysqld restart
7、修改密码,mysql5.7用此语法
use mysql;
update mysql.user set authentication_string=password(‘1111‘) where user=‘root‘;
flush privileges;
8、回到第二步骤去掉加上的
skip-grant-tables
9、以root用户登录
use mysql;
select ‘host‘ from user where user=‘root‘;
update user set host = ‘%‘ where user =‘root‘;
flush privileges;
原文地址:https://www.cnblogs.com/dummyly/p/10047919.html