centos7.4安装mysql
程序员文章站
2024-03-21 18:49:52
...
1.下载官网的yum repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2.使用下载的yum直接安装
rpm -ivh https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
3. 安装MySQL服务器
yum -y install mysql-community-server
4.启动mysql
systemctl start mysqld.service
5.查看mysql运行状态
systemctl status mysqld.service
6.查看mysql安装后的默认密码
grep "password" /var/log/mysqld.log
7.进入mysql数据库
mysql -uroot -p
8.mysql自带密码规则不可以设置过于简单的密码,需要修改规则
set global validate_password_policy=0;
set global validate_password_length=1;
9.修改mysql原始默认密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
10.设置root用的远程访问权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
11.配置阿里云限制端口(全部开放)
12.使用Navicat测试连接
13.my.cnf位置
/etc/my.cnf
14.如果远程连接不上,可以打开防火墙端口
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT