安装mysql
卸载mysql
bash
[bigdata@node101 ~]$ sudo rpm -qa | grep mariadb | xargs sudo rpm -e --nodeps
上传安装包到/opt/software目录并解压
bash
[bigdata@node101 software]$ tar -xf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar -C mysql_lib/
到mysql_lib目录下顺序安装
bash
[bigdata@node101 mysql_lib]$ sudo rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
[bigdata@node101 mysql_lib]$ sudo rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
[bigdata@node101 mysql_lib]$ sudo rpm -ivh mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm
[bigdata@node101 mysql_lib]$ sudo rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
[bigdata@node101 mysql_lib]$ sudo rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm
重启mysql
bash
[bigdata@node101 ~]$ sudo systemctl restart mysqld
查看mysql状态
bash
[bigdata@node101 ~]$ systemctl status mysqld
查看root密码
bash
[bigdata@node101 ~]$ sudo cat /var/log/mysqld.log | grep password
重置密码
bash
[bigdata@node101 ~]$ mysql -uroot -p'lzOkJwdks5+!'
bash
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=6 ;
mysql> set password=password("123456");
mysql> use mysql
设置远程登录
bash
mysql> update user set host="%" where user="root";
mysql> flush privileges;
修改字符集编码
bash
[bigdata@node101 ~]$ sudo vim /etc/my.cnf
bash
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
重启mysql
bash
[bigdata@node101 ~]$ sudo systemctl restart mysqld
设置开机启动
bash
[bigdata@node101 ~]$ sudo vim /etc/rc.d/rc.local
bash
service mysqld start