1.安装MysqL
apt-get install MysqL-server MysqL–client libMysqLclient-dev
3.检查是否安装成功
MysqL –uroot –p
输入密码
5.更改MysqL字符集
输入show variables like ‘char%’;查看会发现两个Latin1的字符集.
MysqL命令输入exit
vi /etc/MysqL/MysqL.conf.d/MysqLd.cnf
打开MysqLd.cnf,并在lc-messages-dir下另起一行输入
character-set-server=utf8注意:是utf8,不是utf-8
保存退出
7.修改另一文件/etc/MysqL/conf.d/MysqL.cnf
vi /etc/MysqL/conf.d/MysqL.cnf
添加一行
default-character-set = utf8
8.重启MysqL
/etc/init.d/MysqL restart
9.进入MysqL检查字符集是否已经更改
10. 让别的机子访问MysqL
vi /etc/MysqL/MysqL.conf.d/MysqLd.cnf
把bind-address修改成如图所示,这样外网的网段就可以访问该数据库(需要配置访问用户及权限)
方法一:
CREATE USER ‘用户名’@’可访问的IP地址’ IDENTIFIED BY ‘密码’;
GRANT ALL PRIVILEGES ON 数据库名.* TO '用户名'@'可访问的IP地址';
示例:创建用户名为lsq,密码为123456的用户,可访问的IP地址为:任意
CREATE USER ‘lsq’@’%’ IDENTIFIED BY ‘123456’;
GRANT ALL PRIVILEGES ON abc.* TO 'lsq'@'%';
方法二:
GRANT ALL PRIVILEGES ON 数据库名.* TO '用户名'@'可访问的IP地址' IDENTIFIED BY '密码' WITH GRANTOPTION;
示例:给lsq授权abc数据库的所有权限
GRANT ALL PRIVILEGES ON abc.* TO 'lsq'@'%' IDENTIFIED BY '123'WITH GRANT OPTION;