Centos 7 使用Yum 安装
1、安装YUM Repo
Repo地址可从官方获取:https://dev.mysql.com/downloads/repo/yum/
这里选择的是 Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package(原因是CentOS就是RedHat重新编译的版本)。下载地址可以点击链接查看,或自己按照规则拼接:wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
完成后可以检测下md5是否与页面上的一致:md5sum m mysql57-community-release-el7-9.noarch.rpm
然后进行repo的安装:rpm -ivh mysql57-community-release-el7-9.noarch.rpm
2、安装MySQL
yum y install mysql-server
3、MySQL的启动配置
systemctl start mysqld #启动MySQL
systemctl stop mysqld #关闭MySQL
systemctl restart mysqld #重启MySQL
systemctl status mysqld #查看MySQL运行状态
systemctl enable mysqld #设置开机启动
systemctl disable mysqld #关闭开机启动
4、修改密码
grep 'temporary password' /var/log/mysqld.log #获取安装时的临时密码
mysql -uroot -p
set global validate_password_policy=0; #修改密码策略
set global validate_password_length=4; #修改密码最小长度
set PASSWORD=PASSWORD('root')
flush privileges;
5、其他配置
表名不区分大小写:vim /etc/my.cnf
在[mysqld]下加上lower_case_table_names=1
外网访问:update user set host = '%' where user ='root';
flush privileges;