CentOS7下yum安装MySQL

CentOS7下yum安装MySQL

  1. 下载rpm包
  wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
  1. 安装mysql yum repository
 yum localinstall mysql57-community-release-el7-11.noarch.rpm
  1. 确认yum repository已经安装
 yum repolist enabled | grep "mysql.*-community.*"
  1. 安装mysql-community-server
 yum install mysql-community-server
  1. 配置MySQL:
    进行此步前需要先reboot一下
    查看生成mysql root用户临时密码:
grep 'password' /var/log/mysqld.log | head -n 1
mysql -u root -p

输入刚刚生成的密码

  1. 设置密码:
    此处需要注意root用户的密码需要大小写字母+数字+特殊符号
mysql> set password for 'root'@'localhost' =password('password');
Query OK, 0 rows affected (0.00 sec)
mysql> 
  1. 把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户
mysql> grant all privileges on *.* to root@'%'identified by 'password';
  1. 修改/etc/my.cnf字符集,防止数据读写的时候乱码
 # 在[mysqld]下面添加
character_set_server=utf8
init_connect='SET NAMES utf8'

# 设置mysql客户端默认字符集添加如下内容
[mysql]
default-character-set=utf8 
socket=/var/lib/mysql/mysql.sock

MySQL默认端口是3306必须开启
可以采用如下方法开启

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

MySQL常用命令:
启动 MySQL: service mysqld start
重启 MySQL: service mysqld restart

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值