1.官网下载地址
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
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
7.安装mysql的 server、client、common、libs、lib-compat
rpm -ivh --nodepsmysql-community-server-5.7.19-1.el7.x86_64.rpm
rpm -ivh --nodepsmysql-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 -ivhmysql-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 generatedfor root@localhost:cO3e&shrqhFt
12.登录mysql服务
mysql -uroot -p 然后粘贴上密码
13.修改mysql密码规则
0 or LOW长度
1 or MEDIUM长度、大小写、数字、特殊字符
2 or STRONG长度、大小写、数字、特殊字符、词典
[if !supportLists]a. [endif]密码强度检查等级,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> use mysql;
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_dictionary_file | |
| validate_password_length | 3 |
| validate_password_mixed_case_count | 0 |
| validate_password_number_count | 3 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 0 |
+--------------------------------------+-------+
14.修改密码:'000000'为新密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('000000');
15.修改远程登录权限
如上图所示:这个是可以成功远程链接得配置
大家默认的%的位置是localhost,即意味着只能本机访问
查询当前user表内root的登录权限:
selecthost,user from mysql.user;
修改权限为所有%:
update mysql.user set host = '%' where user ='root';
刷新缓存:
flush privileges;