mysql5.7安装

2024-10-09 08:42:58 浏览数 (1)

1.查询是否有mysql的安装:rpm -qa | grep mysql 查询是否有Mariadb的安装:rpm -qa | grep mariadb 如果有卸载掉:yum -y remove 文件名

2.下载安装包文件 https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.36-1.el7.x86_64.rpm-bundle.tar 通过xftp上传到服务器

mkdir mysql-5.7.36 tar xvf mysql-5.7.36-1.el7.x86_64.rpm-bundle.tar -C ./mysql-5.7.36

rpm -qa | grep mariadb yum -y remove mariadb-libs.x86_64

3.安装: rpm -ivh mysql-community-common-5.7.35-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-5.7.35-1.el7.x86_64.rpm rpm -ivh mysql-community-client-5.7.35-1.el7.x86_64.rpm rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpm

#4.启动mysql [root@VM-4-3-centos mysql-5.7.36]# systemctl start mysqld

#5.查看mysql进程 [root@VM-4-3-centos mysql-5.7.36]# ps -ef | grep mysql mysql 4376 1 2 16:22 ? 00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid root 4423 2128 0 16:22 pts/0 00:00:00 grep --color=auto mysql

#6.查看安装密码 root账号,密码:_sKJVHsy&71= [root@VM-4-3-centos mysql-5.7.36]# cat /var/log/mysqld.log | grep password 2022-06-01T08:22:19.029894Z 1 [Note] A temporary password is generated for root@localhost: _sKJVHsy&71= [root@VM-4-3-centos mysql-5.7.36]#

7.登录:mysql -u root -p

8.修改密码 修改密码,直接修改会有一个密码复杂度校验,关闭这个校验,编辑文件my.cnf:vim /etc/my.cnf 在[mysqld]下一行加入:validate_password=off 重启mysql服务:systemctl restart mysqld 重新进入sql修改密码:alter user 'root'@'localhost' identified by '123456';

9.更改远程访问:默认禁止(在腾讯云中是由服务器防火墙策略来控制的,需要打开) 1、更改权限,执行语句中账号密码为系统账号密码(mysql下执行) GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;

跟vim /etc/my.cnf 文件中增加: bind_address=0.0.0.0  或者 bind_address=* 没有关系,跟网络策略有关系,添加规则之后,客户端sqlyog就可以正常连接了。

0 人点赞