首页 > 代码库 > Mysql re-set password, mysql set encode utf8 mysql重置密码,mysql设置存储编码格式
Mysql re-set password, mysql set encode utf8 mysql重置密码,mysql设置存储编码格式
There is a link about how to re-set password.
http://database.51cto.com/art/201010/229528.htm
words in short,
two lines
mysql> UPDATE mysql.user SET password=PASSWORD(‘your_new_password‘) WHERE User=‘root‘; mysql> FLUSH PRIVILEGES;
and about mysql encoding:
here is a helpful link: http://www.linuxidc.com/Linux/2013-11/93011.htm
___
首先这是我一开始的Ubuntu 下MySQL默认字符集(下图),在Java中输入中文到数据库中全是乱码问号,MySQL不识别,是因为MySQL默认的字符集是latin1(ISO_8859_1)不是utf8的字符集。
修改方法:
1.打开my.cnf文件进行修改(这里注意下,MySQL版本是5.5以上的,以下版本应该也通用,具体没有测试过,但在5.5以上的绝对可行)
sudo gedit /etc/mysql/my.cnf
2.在[mysqld]下添加如下代码(对于5.5以上版本,[mysqld]的default字符集设置已经是遗弃的参数,可以使用这几个,具体查看相应版本的手册)
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake
3.退出重启mysql服务
sudo service mysql restart
4.进入mysql查看字符集
mysql> show variables like ‘collation_%‘;
mysql> show variables like ‘character_set_%‘;
____Thanks for his sharing!