CentOS6.5安裝MySQL5.7
以hadoop用戶登陸系統,
1.檢測系統是否已經安裝過mysql或其依賴,若已裝過要先將其刪除,不然第4步使用yum安裝時會報錯:
#查看mysql是否安裝,若是已經安裝須要卸載,若是是
sudo rpm -qa|grep mysql
二、若是存在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
三、解壓依次安裝
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
四、啓動服務
sudo service mysqld start #啓動mysqld服務
五、修改配置文件無密碼登陸
sudo vi /etc/my.cnf
在最尾部加上
skip-grant-tables
保存
六、重啓mysql服務
sudo service mysqld restart
七、修改密碼,mysql5.7用此語法
use mysql;
update mysql.user set authentication_string=password('1111') where user='root';
flush privileges;
八、回到第二步驟去掉加上的
skip-grant-tables
九、以root用戶登陸 use mysql; select 'host' from user where user='root'; update user set host = '%' where user ='root'; flush privileges;