CentOS6.8 安装配置Mysql
作者:互联网
1、下载mysql的repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2、安装mysql-community-release-el7-5.noarch.rpm包
rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装这个包后,会获得两个mysql的yum repo源:
/etc/yum.repos.d/mysql-community.repo和 /etc/yum.repos.d/mysql-community-source.repo。
安装 yum install mysql-server
若报错:
解决办法:1、vi mysql-community.repo
2、找到mysql-56-community,
将enable置为0 enable=0;
并
重新安装 yum install mysql-server
3、字符集配置(/etc/my.cnf)
在[mysqld]节点下添加
default-character-set=utf8
character-set-server=utf8
保存退出:wq
4、中文乱码配置,windos下配置my.ini
(1)在5.1版本时,my.ini内【mysql】和【mysqld】中都写:
default-character-set=utf8
(2)而在5.5版本,【mysql】内这么写,【mysqld】内不能,而是:
character-set-server=utf8
5、自启动配置
(1)执行chkconfig mysqld on
(2)执行chkconfig --list mysqld(查看2-5位为on,即为ok)
6、防火墙配置
(1)sudo vi /etc/sysconfig/iptables
(2)-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT 添加到里面
(3)重启防火墙 service iptables restart
7、重启mysql service mysqld restart
8、用户配置
(1)查看当前用户 select user,host,password from mysql.user;
(2)删除匿名用户 delete from mysql.user where user="";
(3)为root设置密码 set password for root@localhost=password('yourpassword');
(4)添加用户 insert into mysql.user(host,user,password) values('localhost','yourUserName',password('yourpassword'));
(5)创建库 create database `databaseName` default character set utf8 collate utf8_general_ci;
(6)本地用户赋予所有的权限
grant all privileges on databaseName.* to yourusername@localhost identified by `yourpassword`;
给账号开通外网所有的权限。
grant all privileges on databaseName.* to yourusername@'%' identified by `yourpassword`;
结合实际情况决定开通什么权限!!!
grant select,insert,update on databaseName.* to yourusername@'192.168.10.205' identified by `yourpassword`;
(7)使操作生效 flush privileges;
标签:set,utf8,Mysql,community,repo,mysqld,CentOS6.8,mysql,安装 来源: https://www.cnblogs.com/baixiong/p/11849225.html