一、环境:Centos 7.0 64位二、mysql版本:5.7三、安装:https://dev.mysql.com/doc/refman/5.7/en/installing.html3.一、建立mysql用户和组:https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html3.二、忘记 linux下mysql5.7 root用户的密码: service mysqld stop 修改/etc/my.inf 末尾添加 skip-grant-tables service mysqld start use mysql update user set authentication_string=password('Kd8k&dfdl023') where user='root'; flush privileges; 将/etc/my.inf中的skip-grant-tables 删掉; service mysqld restart mysql -uroot -p use mysql set password=password('newpassword');3.三、建立mysql用户 https://dev.mysql.com/doc/refman/5.7/en/adding-users.html mysql> CREATE USER 'finley'@'localhost' IDENTIFIED BY 'some_pass'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'trade'@'%' WITH GRANT OPTION;3.五、查看mysql端口: mysql> show variables like 'port';3.四、打开防火墙配置文件: 关闭并禁止firewall开机启动: 中止 systemctl stop firewalld.service 禁止开机启动 systemctl disable firewalld.service 安装iptables防火墙 yum install iptables-services 编辑防火墙配置文件打开指定的端口号使用udp协议打开52100端口: vi /etc/sysconfig/iptables 保存退出 :wq 最后重启防火墙使配置生效 systemctl restart iptables.service 设置防火墙开机启动 systemctl enable iptables.service3.五、查询mysql配置文件 locate my.cnf 查看mysql默认读取的配置列表: mysql --help|grep 'my.cnf' 查看3306端口信息: netstat -apn|grep 3306 修改mysql设置中的bind-address选项: bind-address = 0.0.0.0 修改mysql设置中的port选项: port=3308 ----->使用阿里云服务器,需额外配置阿里云安全规则,设置入场端口!!!!!(巨坑。。)四、建立数据库和数据表们:见sql文件。五、centos设置cmd为支持中文 echo $LANG yum group list yum install system-config-users yum groupinstall chinese-support5.一、linux设置mysql编码为utf-8六、linux 命令执行.sql文件 登陆mysql 执行 source sqlpath