记录一次linux CentOS 安装MySQL5.6.32 全过程
cd /
mkdir /app/
cd /app
上传文件
#解压
tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
#复制解压后的mysql目录
cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
#添加用户组
groupadd mysql
#添加用户mysql 到用户组mysql
useradd -g mysql mysql
#安装
cd /usr/local/mysql/
mkdir ./data/mysql
chown -R mysql:mysql ./
#安装 perl库
yum -y install perl perl-devel
安装autoconf库
yum -y install autoconf
安装
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
注意如果提示文件重复 一定记得 输入’y’后再回车!!!
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
注意如果提示文件重复 一定记得 输入’y’后再回车!!!
cp support-files/my-default.cnf /etc/my.cnf
chmod 755 /etc/my.cnf
#修改启动脚本
vi /etc/init.d/mysqld
#修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
#启动服务
service mysqld start
#以root账户登录mysql,默认是没有密码的
cd /usr/local/mysql
./bin/mysql -uroot -p
#设置localhost root账户密码为 system (也可以修改成你要的密码)
mysql>use mysql;
mysql>update user set password=password('system') where user='root' and host='localhost';
mysql>flush privileges;
#设置远程主机登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
创建用户支持远程链接:
mysql> create database coredbta;
mysql> create user buyside;
mysql> flush privileges;
mysql> grant all on coredbta.* to 'buyside'@'%' ;
mysql> flush privileges;
mysql> show grants for 'buyside'@'%';
正确的添加用户方法:
GRANT USAGE ON *.* TO 'buyside'@'%' IDENTIFIED BY 'buyside' WITH GRANT OPTION;
#注意关闭防火墙
service firewalld stop 关闭
常用命令:
启动mysql
service mysqld start
#关闭mysql
service mysqld stop
#查看运行状态
service mysqld status
重启、关闭、开启firewalld.service服务
service firewalld restart 重启
service firewalld start 开启
service firewalld stop 关闭
防火墙添加端口:
firewall-cmd --list-ports
没有就开启 firewall-cmd --zone=public --add-port=3306/tcp --permanen
然后重启防火墙 firewall-cmd --reload