CentOS 6.8 安装 MysqL 5.1
安装
@H_502_8@sudo yum -y install MysqL-server
直接从阿里云上面下载sudo vim /etc/my.cnf
如图 设置utf8 sudo chkconfig MysqLd on
,sudo chkconfig --list MysqLd
2345 都是启动的话说明设置ok 如下图 sudo vim /etc/sysconfig/iptables
这个文件 开放3306 端口
-A INPUT -t tcp -m --dport 3306 -j AEECPT
:wq 保存退出,
sudo service iptables restart
重启防火墙 配置
@H_502_8@service MysqLd start
MysqL -u root
select user,host,password from MysqL.user;
set password for root@localhost=password('yourpassword');
删除匿名用户
执行 sql 查询是否含有匿名用户select user,password from MysqL.user;
删除匿名 sql delete from MysqL.user where user='';
创建一个database
create database `mall` default character set utf8 collate utf8_general_ci;
本地用户赋予所有权限
grant all privileges on mall.* to 'yourusername'@localhost identified by 'yourpassword'
这里的mall.* 表示 数据库mall 下的所有表,yourname 这里不需要加引号,yourpassword 这里需要加
开通外网所有权限
grant all privileges on mall.* to 'yourusername'@'%'identified by 'yourpassword'
与本地唯一不同的是 @ 后面的ip地址改成了 %,表示不限制IP访问,如果是要开通部分权限给指定的用户 可以这样 eg. 给这个用户开通增查权限
grant all select,insert on mall.* to 'yourusername'@'192.168.2.115'identified by 'yourpassword'