我现在用的是mysql5.7,操作系统centos
配置YUM源
下载mysql源安装包
[root@VM_0_9_centos software]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装mysql源
[root@VM_0_9_centos software]# yum localinstall mysql57-community-release-el7-8.noarch.rpm
安装MySQL
[root@VM_0_9_centos software]# yum localinstall mysql57-community-release-el7-8.noarch.rpm
启动mysql
systemctl start mysqld
启动完了之后,查看mysql状态
systemctl status mysqld
开机启动mysql
[root@VM_0_9_centos software]# systemctl enable mysqld
[root@VM_0_9_centos software]# systemctl daemon-reload
修改root本地登录密码
ysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
[root@VM_0_9_centos software]# grep 'temporary password' /var/log/mysqld.log
2018-06-16T08:05:45.944135Z 1 [Note] A temporary password is generated for root@localhost: oOo;3qdZL0sq
shell> mysql -uroot -poOo;3qdZL0sq
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误*
####添加远程登录用户
默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户,为了安全起见,我们添加一个新的帐户glowd,并且允许所有的ip地址远程访问:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'glowd'@'%' IDENTIFIED BY 'glowd7^&!'
配置默认编码为utf8mb4
最新的mysql数据库默认编码已经是utf8mb4,这能避免很多不必要的问题。
修改/etc/my.cnf配置文件,最终的配置如下
[client]
<