安装
sudo apt-get install mysql-server =》 安装最新版MySQL服务器
sudo apt-get install libmysqlclient-dev =》 安装开发包
#修改密码和创建账户
sudo cat /etc/mysql/debian.cnf
[client]
host = localhost
user = debian-sys-maint 《============== 初始的用户名
password = Kk3TbShbFNvjvhpM 《=============== 初始的密码
socket = /var/run/mysqld/mysqld.sock
mysql -u debian-sys-maint -pKk3TbShbFNvjvhpM
命令解释: -u后面是上面查看的用户名 -p后面紧跟上面查看的密码
mysql> update mysql.user set authentication_string=password('123456') where
user='root' and host='localhost';
mysql> update mysql.user set plugin="mysql_native_password";
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
mysql> show variables like "char%"; # 先查看MySQL默认的字符编码
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 | 《============不支持中
文!!!
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.06 sec)
mysql> set character_set_server=utf8;
Query OK, 0 rows affected (0.00 sec)
修改表的字符编码:alter table user default character set utf8;
修改属性的字符编码:alter table user modify column name varchar(50) character set utf8;