// 安装MySQL
$ wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
$ yum localinstall -y mysql57-community-release-el7-7.noarch.rpm
$ yum install -y mysql-community-server
// 设置跳过登陆
$ systemctl stop mysqld
$ systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
$ systemctl start mysqld
$ mysql -u root
// 密码要求更高的复杂度 否则可能报错
mysql> UPDATE mysql.user SET authentication_string = PASSWORD('@root#1234:M') WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit
// 还原设置
$ systemctl stop mysqld
$ systemctl unset-environment MYSQLD_OPTS
$ systemctl start mysqld
$ mysql -u root -p
// 设置新密码
mysql> SET PASSWORD = PASSWORD('@root#1234:M');
// 到此可正常使用了
更多命令
// 创建用户
mysql> CREATE USER 'app'@'localhost' IDENTIFIED BY '@app1234';
// 创建数据库
mysql> create database chat;
// 设置用户权限
mysql> grant ALL on chat.* to app@'localhost';
// 执行sql文件
mysql> source /root/db.sql