1.到官网下载mysql:
http://dev.mysql.com/downloads/mysql/
选择redhat版本,因为redhat和centos是同一家公司的,都差不多
下载地址: https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar
下载完成后解压:
下载好了是:mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar
解压: tar xf mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar
解压出来有好几个文件,需要顺序去安装
解压出来的文件:
mysql-community-client-5.7.23-1.el7.x86_64.rpm
mysql-community-common-5.7.23-1.el7.x86_64.rpm
mysql-community-devel-5.7.23-1.el7.x86_64.rpm
mysql-community-embedded-5.7.23-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.23-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.23-1.el7.x86_64.rpm
mysql-community-libs-5.7.23-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.23-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.23-1.el7.x86_64.rpm
mysql-community-server-5.7.23-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.23-1.el7.x86_64.rpm
mysql-community-test-5.7.23-1.el7.x86_64.rpm
第一:
rpm -ivh mysql-community-common-5.7.23-1.el7.x86_64.rpm
第二:
rpm -ivh mysql-community-libs-5.7.23-1.el7.x86_64.rpm
第三:
rpm -ivh mysql-community-client-5.7.23-1.el7.x86_64.rpm
第四:
rpm -ivh mysql-community-server-5.7.23-1.el7.x86_64.rpm
最后启动mysql:
service mysqld restart
这时候又会碰到困难,没有密码进不去:
在/ect/my.cnf 的最后面加上一行:
skip-grant-tables
保存退出
重启mysql服务:service mysqld restart
然后再连接mysql就可以了
mysql -u root
update mysql.user set authentication_string=password('123qwe') where user='root';
然后再把my.cnf里面加的那行删掉,然后再用root账号和密码进入mysql
进去之后需要重新设置root密码:
SET PASSWORD = PASSWORD(‘your new password‘);
ALTER USER ‘root‘@‘localhost‘ PASSWORD EXPIRE NEVER;
这个密码必须符合密码规范
flush privileges;(使立即生效)
设置远程可以登录:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
FLUSH PRIVILEGES;
然后用远程访问,测试是否可以连接:
如果不可以连接,查看防火墙是否开通