操作系统:mint 17.2
1.安装mysql(5.5)
sudo apt-get update
sudo apt-get install mysql-server
2.检查mysql是否安装
dpkg -l|grep mysql
3.配置文件
/etc/mysql/my.cnf
4.字符集配置
编辑配置文件
sudo gedit /etc/mysql/my.cnf
在[mysqld]节点下面添加:character_set_server=utf8
在[client]和[mysql]这个两个节点下面添加
default-character-set=utf8
自动启动配置
sudo update-rc.d mysql defaults
防火墙的配置
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
启动mysql的服务
sudo /etc/init.d/mysql start
mysql初始化环境配置
mysql -u root -p
Mysql的配置
查看目前的mysql用户
select user,host,password from mysql.user;
修改root用户密码
set password for root@localhost=password("alex");
set password for root@127.0.0.1=password("alex")
删除匿名用户
delete from mysql.user where user='';
刷新:
flush privileges;使得配置生效
插入mysql新用户
insert into mysql.user(Host,User,Password) values("localhost","alex",password("alex"));
flush privileges;
创建数据库:
create database `databasename` default character set utf8 collate utf8_general_ci;
本地用户赋予所有权限
grant all privileges on databasename.* to alex@localhost identified by "alex";
开通账号外网权限:
grant all privileges on databasename.* to alex@'%' identified by "alex";
也可以根据需要给账号开通外网权限
grant select on databasename.* to alex@‘192.167.0.11' identified by "alex";
flush privileges;