MySQL 远程访问及中文乱码问题

MySQL 远程访问问题
1.sudo vim mysql.conf.d/mysqld.cnf
   注掉 #bind-address           = 127.0.0.1
2.登陆进入mysql
xuhui@xuhui-ubuntu-server:/etc/mysql$ mysql -uroot -p
   Enter password:
   mysql> use mysql
   mysql> update user set Host = '%' where user = 'root';
   GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'lixiul' WITH GRANT OPTION;  //授权来自任何机器 可以以用户名root,密码lixiul登陆mysql服务器
   FLUSH PRIVILEGES; //保存修改
  3. service mysql restart  //重启mysql服务

 

 


MySQL 中文乱码问题
1 修改/etc/mysql/my.cnf
添加如下内容
[mysqld]
character-set-server=utf8

[mysql.server]
default-character-set=utf8

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

2 重启mysql

service mysql restart


3 进入mysql

mysql>  SHOW VARIABLES LIKE 'character_%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

mysql>

 

 

你可能感兴趣的:(DB,数据库,开发工具)