一、配置YUM源html
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpmmysql
shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查MySQL源是否安装成功
shell> yum repolist enabled | grep “mysql.-community.” sql
二、安装MySQL
shell> yum install mysql-community-server
三、启动MySQL服务
shell> systemctl start mysqld
查看MySQL的启动状态
shell> systemctl status mysqldshell
四、开机启动
shell> systemctl enable mysqld
shell> systemctl daemon-reload数据库
五、修改root本地登陆密码
grep ‘temporary password’ /var/log/mysqld.log
mysql -uroot –p+生产注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,而且长度不能少于8位。不然会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误,以下图所示:centos
六、添加远程登陆用户
默认只容许root账户在本地登陆,若是要在其它机器上链接mysql,必须修改root容许远程链接,或者添加一个容许远程链接的账户,
mysql> GRANT ALL PRIVILEGES ON . TO ‘*’@’ localhost’ IDENTIFIED BY ’ MyNewPass4!’ WITH GRANT OPTION;安全
GRANT ALL PRIVILEGES ON . TO ‘*’@’ Spark’ IDENTIFIED BY ’ MyNewPass4!’ WITH GRANT OPTION;socket
七、配置默认编码为utf8ide
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,以下所示:
[mysqld]
character_set_server=utf8
init_connect=’SET NAMES utf8’post
常见问题:
1.ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this ..
解决:首先修改用户的密码。(下面两个命令一个意思,任选其一便可)
alter user 'root'@'localhost' identified by 'youpassword';
set password=password("youpassword");
而后在刷新权限。
flush privileges;
2.MySQ修改密码报错ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决:
默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
转发自:https://www.centoschina.cn/server/sql/mysql/8661.html