CentOS7安装mysql
安装步骤
#下载mysql社区版本源并安装
wget https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum install -y mysql57-community-release-el7-10.noarch.rpm
#yum安装mysql server
yum install -y mysql-community-server
systemctl start mysqld
#mysql --version查看版本
#查看临时密码
grep 'password' /var/log/mysqld.log
#修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456Hs!';
grant select on mysql.* to peanut@localhost identified by '12345678Aa!';
grant select on mysql.* to 'huasheng'@'%' identified by '12345678Aa!';
#赋予用户增,删,改,查权限
GRANT INSERT,DELETE,UPDATE,SELECT on test.* to 'huasheng'@'%';
#赋予所有权限
GRANT ALL PRIVILEGES on test.* to 'huasheng'@'%';
systemctl restart mysqld
mysql>status
vi /etc/my.cnf
#新增四行代码
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
#重启生效
systemctl restart mysqld
systemctl stop mysqld
systemctl restart mysqld
测试连接

参考
mysql_创建用户及赋予权限