CentOS7 Linux安装mysql

【*】将mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz放到 usr/local文件夹

【*】网盘文件

链接:https://pan.baidu.com/s/1iQKZyiVc6xNpXKyxdqEGBw 
提取码:xge4

【*】解压到当前目录 tar -zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz

【*】具体安装

shell> groupadd mysql #创建mysql用户组
shell>     useradd -r -g mysql mysql
shell> cd /usr/local
shell> ln -s mysql-5.7.9-linux-glibc2.5-x86_64 mysql  #创建软链,以后访问可以直接cd mysql就可以进入复杂名称的文件加,其实就是将mysql的解压文件夹起了别名
shell> cd mysql
shell> mkdir mysql-files
shell> chmod 770 mysql-files
shell> chown -R mysql . #注意后面有点
shell> chgrp -R mysql .
shell> bin/mysqld --initialize --user=mysql #如果没有报错,mysql会给root用户生成一个默认的密码,mysql如果报错执行后面的命令 -->yum install -y libaio 
shell> bin/mysql_ssl_rsa_setup
shell> chown -R root .
shell> mkdir data
shell> chown -R mysql data mysql-files
shell> /usr/local/mysql/bin/mysqld --verbose --help |grep -A 1 'Default options'
shell> cd /etc
shell> mv my.cnf my.cnfbak
shell> 进入mysql的安装目录
shell> bin/mysqld --initialize --user=mysql
shell> bin/mysql_ssl_rsa_setup
shell> chown -R root .
shell> chown -R mysql data mysql-files
shell> bin/mysqld_safe --user=mysql &
shell> ps -ef | grep mysqld
shell> cp support-files/mysql.server /etc/init.d/mysql.server #拷贝mysql的启动文件到linux启动脚本,方便管理mysql的启动脚本
shell> chkconfig --list #查看开机启动项
shell> chkconfig mysql.server on #配置mysql开机启动
shell> chkconfig --list #查看开机启动项,发现mysql已经加入了开机启动项
mysql.server   	0:off	1:off	2:on	3:on	4:on	5:on	6:off
netconsole     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
network        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
shell> vi /etc/profile   #配置mysql环境变量
shell> export PATH=/usr/local/mysql/bin:$PATH #在文件的最后一行加上这句话
shell> source /etc/profile
shell> mysql -uroot -p'sol7R;*ASfC*' #-p后单引号的内容是密码,这个密码是上面的某些步骤完成之后在下面生成的,注意记下来
shell> set password = 'mima'; #重新设置自己mysql的密码,修改密码
#接下来设置允许远程登录
shell> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root1234%' WITH GRANT OPTION;
shell> flush privileges;
shell> show databases; #数据库已经可以查询到
shell> exit #退出mysql
#此时Linxu的mysql在windows上还不一定能够访问成功,需要查询mysql的3306端口是否开放
shell> firewall-cmd --list-ports #我这里防火墙端口未开放
shell> firewall-cmd --zone=public --add-port=3306/tcp --permanent #开放防火墙3306端口
shell> firewall-cmd --reload #重启防火墙
shell> firewall-cmd --list-ports #查看防火墙开放了那些端口,发现3306端口已经打开,此时使用windows的navicat就可以连接访问了。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SuperLBY

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值