/ linux

MySQL install

安装

不同系统有差异,参看官方文档

centos 为例

yum install mysql
yum install mysql-server
yum install mysql-devel

一般 mysql-server 会安装失败,因为系统本身将其移除,我们需要从官网下载安装:

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server

重启

service mysql restart 

添加用户

添加一个名为zhangsan的用户:

create user zhangsan identified by 'zhangsan';

数据库授权

grant all privileges on zhangsanDb.* to zhangsan@'%' identified by 'zhangsan';
flush privileges;

远程连接

设置允许授权 IP 远程登陆对应账号,下面是允许任何 IP 用 root 账号远程登陆:

mysql> set password for 'root'@'localhost' =password('password');

如果无法登陆,查看一下 MySQL 的配置文件里面注释掉

bind-address= 127.0.0.1

参考