6.MYSQL安装

2020-08-17  本文已影响0人  Rex_2013

1. 安装包准备

1.1 卸载自带的Mysql-libs(如果之前安装过mysql,要全都卸载掉)

[root@node09 bin]# rpm -qa | grep -i -E mysql\|mariadb | xargs -n1 sudo rpm -e --nodeps

1.2 将安装包和JDBC驱动上传到/opt/software,共计6个

01_mysql-community-common-5.7.29-1.el7.x86_64.rpm
02_mysql-community-libs-5.7.29-1.el7.x86_64.rpm
03_mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm
04_mysql-community-client-5.7.29-1.el7.x86_64.rpm
05_mysql-community-server-5.7.29-1.el7.x86_64.rpm
mysql-connector-java-5.1.48.jar

2. 安装MySQL

2.1 安装mysql依赖

[root@node09 07_mysql]# sudo rpm -ivh 01_mysql-community-common-5.7.29-1.el7.x86_64.rpm
[root@node09 07_mysql]# sudo rpm -ivh 02_mysql-community-libs-5.7.29-1.el7.x86_64.rpm
[root@node09 07_mysql]# sudo rpm -ivh 03_mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm

2.2 安装mysql-client

[root@node09 07_mysql]#  sudo rpm -ivh 04_mysql-community-client-5.7.29-1.el7.x86_64.rpm

2.3 安装mysql-server

[root@node09 07_mysql]# sudo rpm -ivh 05_mysql-community-server-5.7.29-1.el7.x86_64.rpm

2.4 启动mysql

[root@node09 07_mysql]# sudo systemctl start mysqld

2.5 查看mysql密码

[root@node09 07_mysql]# sudo cat /var/log/mysqld.log | grep password

3 配置MySQL

目的:配置只要是root用户+密码,在任何主机上都能登录MySQL数据库。

3.1用刚刚查到的密码进入mysql

[root@node09 07_mysql]# mysql -uroot -p'(DKEk+oJl3iu'

3.2 更改mysql密码策略

mysql> set global validate_password_length=4;
mysql> set global validate_password_policy=0;

3.3 设置简单好记的密码

mysql> set password=password("000000");

3.4 进入msyql库

mysql> use mysql

3.5 查询user表

mysql> select user, host from user;

3.6 修改user表,把Host表内容修改为%

mysql> update user set host="%" where user="root";

3.7 刷新

mysql> flush privileges;

3.8 退出

mysql> quit;
上一篇下一篇

猜你喜欢

热点阅读