MySQL单机版安装

来源:互联网 发布:mac安装tomcat 编辑:程序博客网 时间:2024/05/17 08:11

准备环境:

CentOS 7.4 64位

关闭防火墙

关闭selinux


安装常用工具:

[root@localhost ~]# yum install -y vim tree wget


下载rpm:

[root@localhost ~]# wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm


安装yum源:

[root@localhost ~]# yum install mysql57-community-release-el7-11.noarch.rpm


安装mysql:

[root@localhost ~]# yum install -y mysql-community-server


启动mysql:

[root@localhost ~]# systemctl start mysqld.service


检查mysql启动状态:

[root@localhost ~]# systemctl status mysqld.service


配置mysql开机自启动:

[root@localhost ~]# systemctl enable mysqld.service


第一次登录,获取mysql的root用户初始化密码:

[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log


修改mysql的root用户的密码:

[root@localhost ~]# mysql -uroot -p

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';


常见问题:

1、ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

需要使用ALTER USER修改密码。


2、ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

密码的复杂度不符合要求。


密码策略:

MySQL's validate_password plugin is installed by default. This will require that passwords contain at least one upper case letter, one lower case letter, one digit, and one special character, and that the total password length is at least 8 characters.

yum安装的默认密码策略:至少包含一个大写字符、一个小写字符、一个数字、一个特殊字符,并且密码总长度至少是8个字符。