centos7安装MySQL
下载并安装MySQL官方的 Yum Repository
[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
Yum Repository,大概25KB的样子,然后就可以直接yum安装了。
[root@zjj ~]
安装MySQL服务器。
[root@zjj ~]
安装完成后就会覆盖掉之前自带mariadb。
首先启动MySQL
[root@zjj ~]
MySQL已经开始正常运行,通过如下命令可以在日志文件中找出root密码:
[root@zjj etc]# grep "password" /var/log/mysqld.log
进入数据库
[root@localhost ~]# mysql -uroot -p
输入初始密码(是上面图片最后面的 8pGq?F)ghS9e),MySQL默认必须修改密码之后才能操作数据库:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
关掉mysql密码策略,便可设置简单密码
[mysqld]
validate_password=off
查看密码策略
show VARIABLES like "%password%"
开启mysql的远程访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
刷新权限
mysql> flush privileges;
打开vim /etc/mysql/my.cnf
添加bind-address=0.0.0.0
关闭防火墙
systemctl stop firewalld.service
systemctl status firewalld.service
mysql启动命令
systemctl start mysqld.service
systemctl restart mysqld.service
systemctl enable mysql.service
systemctl stop mysqld.service
|