MySql教程

centos安装mysql

本文主要是介绍centos安装mysql,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

MySql安装
1 安装包准备
1)卸载自带的Mysql-libs
rpm -qa | grep -i -E mysql|mariadb | xargs -n1 sudo rpm -e --nodeps
2)将安装包和JDBC驱动上传
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
1)安装mysql依赖
sudo rpm -ivh 01_mysql-community-common-5.7.29-1.el7.x86_64.rpm
sudo rpm -ivh 02_mysql-community-libs-5.7.29-1.el7.x86_64.rpm
sudo rpm -ivh 03_mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm
2)安装mysql-client
sudo rpm -ivh 04_mysql-community-client-5.7.29-1.el7.x86_64.rpm
3)安装mysql-server
sudo rpm -ivh 05_mysql-community-server-5.7.29-1.el7.x86_64.rpm
4)启动mysql
sudo systemctl start mysqld
5)查看mysql密码
sudo cat /var/log/mysqld.log | grep password
3 配置MySql
配置只要是root用户+密码,在任何主机上都能登录MySQL数据库。
1)用刚刚查到的密码进入mysql(如果报错,给密码加单引号)
mysql -uroot -p’password’
2)设置复杂密码(由于mysql密码策略,此密码必须足够复杂)
mysql> set password=password(“Qs23=zs32”);
3)更改mysql密码策略
mysql> set global validate_password_length=4;
mysql> set global validate_password_policy=0;
4)设置简单好记的密码
mysql> set password=password(“000000”);
5)进入msyql库
mysql> use mysql
6)查询user表
mysql> select user, host from user;
7)修改user表,把Host表内容修改为%
mysql> update user set host="%" where user=“root”;
8)刷新
mysql> flush privileges;
9)退出
mysql> quit;

这篇关于centos安装mysql的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!