Ubuntu下安装MySQL
2017-05-23 本文已影响28人
wildtree001
删除mysql
- mysql -V 查看mysql版本
- sudo apt-get autoremove --purge mysql-server-版本号
sudo apt-get remove mysql-server
sudo apt-get remove mysql-common - 清理残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
安装mysql
- sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev - 检查是否安装成功:
sudo netstat -tap | grep mysql
mysql常用命令
- mysql -u root -p
- show databases;
- use database;
- show tables;
- source xxx.sql 导入
- DDL,DML...
修改默认字符
-
查看MySQL编码,有两个不是utf8
show variables like 'character%'; -
vim /etc/mysql/mysql.conf.d/mysqld.cnf
在lc-messages-dir = /usr/share/mysql 语句后添加 character-set-server=utf8 语句
character-set-server=utf8 -
vim /etc/mysql/conf.d/mysql.cnf
添加:default-character-set=utf8
default-character-set=utf8 -
/etc/init.d/mysql restart 命令重启MySQL服务
重启后再次查看编码
end