1. 概述
- 最近没啥东西可写, 随便写点
- mysql 5.6 的安装
- 去年写的
- 装上去过 三次以上
2. 准备
- 系统
- CentOS 7.4
3. 安装
1. 直接安装
# mysql服务端: mysql-server,mysql-devel
# mysql客户端: mysql
# 其实 mysql-server 没装上
> yum install -y mysql-server mysql-devel mysql
2. 获取mysql-server源的rpm包
> wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
3. 安装源,通过rpm
> rpm -ivh mysql-community-release-el7-5.noarch.rpm
4. 检验源
> ls -1 /etc/yum.repos.d/mysql-community*
/etc/yum.repos.d/mysql-community.repo
/etc/yum.repos.d/mysql-community-source.repo
5. 安装mysql
> yum install -y mysql-server
6. 验证
> rpm -qa | grep mysql
mysql-community-release-el7-5.noarch # 这个是源
mysql-community-libs-5.6.39-2.el7.x86_64
mysql-community-devel-5.6.39-2.el7.x86_64
mysql-community-common-5.6.39-2.el7.x86_64
mysql-community-client-5.6.39-2.el7.x86_64
mysql-community-server-5.6.39-2.el7.x86_64
7. 启动
- 启动mysql
> systemctl start mysql
> systemctl status mysql
- 查看状态
> systemctl status mysql
- 登录mysql
# 这个时候是没有密码的,root可以直接登录
> mysql -uroot
8. 配置权限
- 配置默认密码
# 刚开始mysql是没有密码的,所以可以直接这么改
# 如果设置了密码之后,需要加别的参数,确保你是root
> mysqladmin -u root password 123456
- 登录
> mysql -uroot -p123456
- 为修改root用户登录地址,解除限制
mysql> use mysql;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql> select host, user, password from user;
# 这个好像不刷也是可以的,起码我sqlyog试了可以
mysql> flush privileges;
- 创建用户
# 创建用户
mysql> create user 'username'@'localhost' identified by 'password';
# 授权
mysql> grant all privileges on *.* to username@'%'identified by 'password';
4. ref
- 安装
http://blog.csdn.net/u010246789/article/details/52382632
- 用户权限
# 添加密码的时候,不能直接输,需要使用password函数
https://www.cnblogs.com/starof/p/4680083.html
- mysql的repo
https://repo.mysql.com/