时间:2021-07-01 10:21:17 帮助过:18人阅读
4、重启mysql服务 sudo service mysqld restart
5、mysql>show variables like ‘character_set%‘;
进入mysql控制台后,执行以下命令
修改默认字符集 1.1修改服务器默认字符集 set character_set_server=utf8 1.2修改数据库字符集 set character_set_database=utf8; 1.3修改数据库客户端字符集 set character_set_client=utf8; 1.4修改连接默认字符集 set character_set_connection=utf8
修改已经存在库的字符集 2.1修改存在数据库的字符集 alter database mydb character set utf8; 2.2修改存在表的字符集 alter table mytable default character set utf8
结果如下:
+--------------------------+----------------------------+ | 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/ | +--------------------------+----------------------------+
6、其他一些常用命令
设置密码 use mysql; update user set password=password(‘密码‘) where user=‘root‘; flush privileges;
授权
grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘ with grant option;
CentOS修改Mysql字符集
标签:com roo security link grant variable show sql 常用