MySQL安装配置
- 官网下载地址
https://dev.mysql.com/downloads/file/?id=471503
mysql-5.7.19-1.el7.x86_64.rpm-bundle
2.检测本地是否有mysql已存在的包
rpm -qa | grep mysql
3.检测本地是否有mariadb已存在的包
rpm -qa | grep mariadb
4.如果存在,则使用yum命令卸载
mariadb-libs-5.5.56-2.el7.x86_64
yum -y remove mariadb-libs-5.5.56-2.el7.x86_64
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
5.创建一个文件夹,上传jar包到/opt/software/mysql
mkdir /opt/software/mysql
6.解压mysql jar包
tar -xvf mysql-5.7.19-1.el7.x86_64.rpm-bundle.tar -C /opt/module/mysql
7.安装mysql的 server、client、common、libs、lib-compat
rpm -ivh --nodeps mysql-community-server-5.7.19-1.el7.x86_64.rpm
rpm -ivh --nodeps mysql-community-client-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.19-1.el7.x86_64.rpm
8.查看mysql的服务是否启动
systemctl status mysqld
Active: inactive (dead)
9.启动mysql的服务
systemctl start mysqld
10.再次检查mysql的服务是否启动
systemctl status mysqld
Active: active (running) since Thu 2019-03-21 07:23:08 EDT; 2s ago
11.查看默认生成的密码
cat /var/log/mysqld.log | grep password
2019-03-21T11:23:01.643479Z 1 [Note] A temporary password is generated for root@localhost: iwkJGgd:j6jO
12.登录mysql服务
mysql -uroot -p’然后粘贴上密码’
13.修改mysql密码规则
0 or LOW | 长度 |
1 or MEDIUM | 长度、大小写、数字、特殊字符 |
2 or STRONG | 长度、大小写、数字、特殊字符、词典 |
注:以下修改是临时修改
- 密码强度检查等级,0/LOW、1/MEDIUM、2/STRONG
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.05 sec)
b.密码至少要包含的小写字母个数和大写字母个数
mysql> set global validate_password_mixed_case_count=0;
Query OK, 0 rows affected (0.00 sec)
c.密码至少要包含的数字个数
mysql> set global validate_password_number_count=3;
Query OK, 0 rows affected (0.00 sec)
d.密码至少要包含的特殊字符数
mysql> set global validate_password_special_char_count=0;
Query OK, 0 rows affected (0.00 sec)
e.密码最小长度,参数默认为8,
它有最小值的限制,最小值为:validate_password_number_count + 密码至少要包含的数字个数validate_password_special_char_count +特殊字符
(2 * validate_password_mixed_case_count)至少要包含的小写字母个数和大写字母个数
mysql> set global validate_password_length=3;
Query OK, 0 rows affected (0.00 sec)
- 修改密码:
mysql> set password for root@localhost = password('000000');
(跳过这句,因为容易出错)GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '000000' WITH GRANT OPTION;
2.查询当前user表内root的登录权限:
mysql> select host,user from mysql.user;
3.修改权限为所有%:
mysql> update mysql.user set host = '%' where user = 'root';
4.刷新缓存:
mysql> flush privileges;