前言
CentOS7.4部署Mysql随手笔记,可以作为部署参考。
一、查看一下系统上的mariadb
rpm -qa | grep mariadb
如果有就卸载
yum remove mariadb-libs
二、安装Mysql
1.解压mysql安装包
tar -xvf mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
安装rpm包
rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm
2.设置mysql免密码登录
vim /etc/my.cnf
在任意一行加入:skip-grant-tables
3.启动mysql服务
systemctl start mysqld
4.进入mysql
mysql -uroot -p
输入密码直接回车
use mysql
修改密码:
update mysql.user set authentication_string=password('新密码') where user='root';
刷新权限
flush privileges;
编辑my.cnf文件删除skip-grant-tables
重启mysql服务
systemctl restart mysqld
再次通过刚刚修改的密码进入mysql重新修改一下密码并刷新权限
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
flush privileges;
5.授权root远程登陆
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
flush privileges;
设置开机自启动
systemctl enable mysqld