一、下载mysql5.7的rpm安装包
rpm的mysql包,安装起来简单,解压版的mysql还需要做许多配置,稍有不慎就会出错!!!
二、上传mysql安装包到centos7的系统下
系统配置
三、安装依赖
3.1、 查看linux上是否已经安装了mysql,有则卸载
一般centos7默认安装了mariadb,这里把它卸载
[root@hdp02 mysql]# rpm -qa|grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@hdp02 mysql]# rpm -e mariadb-libs-5.5.52-1.el7.x86_64
error: Failed dependencies:
libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
[root@hdp02 mysql]# rpm -qa|grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@hdp02 mysql]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
3.2 、安装mysql5.7所需要的依赖
重点:安装这个版本的mysql ,这三个 一定要安装 ,不然可能会出错,安了又不吃亏,切记要装,别人我不知道,自己一定要装!
[root@hdp02 mysql]# yum install libaio
[root@hdp02 mysql]# yum install perl
[root@hdp02 mysql]# yum install net-tools
yum install libaio
yum install perl
yum install net-tools
四、安装
4.1、安装的顺序如下图
4.2. 按照顺序安装
[root@hdp02 mysql]# rpm -ivh mysql-community-common-5.7.19-1.el6.x86_64.rpm
[root@hdp02 mysql]# rpm -ivh mysql-community-libs-5.7.19-1.el6.x86_64.rpm
[root@hdp02 mysql]# rpm -ivh mysql-community-client-5.7.19-1.el6.x86_64.rpm
[root@hdp02 mysql]# rpm -ivh --nodeps mysql-community-server-5.7.19-1.el6.x86_64.rpm
rpm -ivh mysql-community-common-5.7.19-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.19-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.19-1.el6.x86_64.rpm
rpm -ivh --nodeps mysql-community-server-5.7.19-1.el6.x86_64.rpm
4.3、启动并且查看启动状态
4.4、 修改密码
[root@hdp01 mysql]# cat /var/log/mysqld.log | grep password
2020-05-26T10:17:28.249686Z 1 [Note] A temporary password is generated for root@localhost: 3#hsL78s1UJy
2020-05-26T10:17:44.747705Z 3 [Note] Access denied for user 'UNKNOWN_MYSQL_USER'@'localhost' (using password: NO)
报密码安全错误:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> set password = password("123456");
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
修改密码安装等级和长度
set global validate_password_policy=LOW;
set global validate_password_length=6;
mysql> set global validate_password_policy=LOW;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=6;
Query OK, 0 rows affected (0.00 sec)
## 展示 密码的等级,长度信息
mysql> show variables like 'valiedate_password%';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
报错:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
退出重新登录
mysql> show variables like 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 6 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 1 |
+--------------------------------------+-------+
7 rows in set (0.00 sec)
4.5 、查看数据库编码
mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
使用命令可以修改 编码方式
set character_set_database = utf8;
set character_set_server = utf8;