linux安装mysql 5.7 完整步骤
linux安装mysql 5.7 完整步骤
1|查询是否有mysql的安装:rpm -qa | grep mysql
查询是否有Mariadb的安装:rpm -qa | grep mariadb
如果有卸载掉:yum -y remove 文件名
2|将tar包解压到指定目录:tar xvf xx.tar -C ./x
我下载的文件地址为:https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.36-1.el7.x86_64.rpm-bundle.tar
3|安装:
rpm -ivh mysql-community-common-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.36-1.el7.x86_64.rpm
4|启动mysql服务:systemctl start mysqld
5|在日志中查询初始密码(最后面的一串大概12位就是):cat /var/log/mysqld.log | grep password
6|登录:mysql -u root -p
安装完成---------------------------------
修改密码,直接修改会有一个密码复杂度校验,关闭这个校验,编辑文件my.cnf:vim /etc/my.cnf
在[mysqld]下一行加入:validate_password=off
重启mysql服务:systemctl restart mysqld
重新进入sql修改密码:alter user 'root'@'localhost' identified by '123456';
上update mysql.user set authentication_string = password ('新密码') where user = 'root' and host = 'localhost';
更改远程访问:默认禁止
1、更改权限,执行语句中账号密码为系统账号密码(mysql下执行)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
2、MySQL查询新增加的权限HOST参数是否为%,代表哪里都可以访问,为1代表本机
select * from mysql.user where user='root' \G;
3、打开防火墙3306端口(退出mysql执行)
firewall-cmd --zone=public --add-port=3306/tcp --permanent
4、查询防火墙开放的端口
firewall-cmd --list-ports
5、重启防火墙
systemctl restart firewalld.service
————————————————
原文链接:https://blog.csdn.net/u011200959/article/details/124346459
更多推荐
所有评论(0)