下载页面:
https://dev.mysql.com/downloads/mysql/5.7.html#downloads
查询是否有mysql相关库
rpm -qa | grep mysql
查询到mysql-libs-5.1.73-8.el6_8.x86_64
卸载之
yum remove mysql-libs
或
rpm -e mysql-libs-5.1.73-8.el6_8.x86_64 --nodeps
下载mysql安装包
wget
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.22-1.el6.x86_64.rpm
wget
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-common-5.7.22-1.el6.x86_64.rpm
wget
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-5.7.22-1.el6.x86_64.rpm
wget
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.22-1.el6.x86_64.rpm
开始安装
安装顺序common -> libs -> client -> server
rpm -ivh mysql-community-common-5.7.22-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.22-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.22-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.22-1.el6.x86_64.rpm
启动mysql服务
service mysqld start
/etc/init.d/mysql start
查看是否启动
ps -ef | grep mysql
netstat -nat | grep 3306
netstat -ntlp | grep mysqld
获取临时密码
cat /var/log/mysqld.log | grep 'temporary password'
登录
mysql -u root -p
修改密码
set password=password("新密码");
创建数据库
create database db1 default character set utf8mb4;
创建并授权远程用户
grant all privileges on db1.* to 'user1'@'IP地址' identified by 'user1';
刷新权限
flush privileges;
查看端口
show global variables like 'port';
检查是否不区分大小写
show variables like '%case_table%';
退出mysql
exit;
修改端口
vim /etc/my.cnf
加入
port=新端口号
忽略大小写
lower_case_table_names=1
重启服务
service mysqld restart
开发端口
vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 端口号 -j ACCEPT
重启防火墙
service iptables restart