安装
需求
ubuntu 18.04 。
- ubuntu 16.04 可能会失败
步骤
sudo apt-get update
sudo apt-get install -y mysql-server
mysql -V
sudo mysql_secure_installation # 看英文,对数据库安全性进行简单配置
# 设置可以远端登录
mysql -uroot -peftales
use mysql;
update user set host='%' where user='root';
flush privileges;
quit;
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
# 删掉 bind-address = 127.0.0.1
# 加上 sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
sudo nano /etc/my.cnf
# 在最后加上
[mysqld]
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci
[client]
default-character-set = utf8
[mysql]
default-character-set = utf8
sudo service mysql restart
启动
sudo service mysql restart
网友评论