转载请注明出处: http://qiudeqing.com/general/2016/10/03/sql.html

登录mysql

mysql -u root -p

mac mysql服务器无法启动

提示Warning, /usr/local/mysql/data is not owned by ‘mysql’ or ‘_mysql’

执行:

cd /usr/local/mysql
sudo chown -R _mysql data/

然后在启动就好了

参考: http://stackoverflow.com/questions/25954230/mysql-does-not-start-when-upgrading-osx-to-yosemite-or-el-capitan

如果数据库指定数据库不存在则创建

CREATE DATABASE IF NOT EXISTS `micro-message` DEFAULT CHARACTER SET = utf8 DEFAULT COLLATE = utf8_unicode_ci;

那么在这个数据库下创建的所有数据表的默认字符集都会是utf8了,注意后面这句话 “COLLATE utf8_general_ci”,大致意思是在排序时根据utf8变码格式来排序