https://www.cnblogs.com/luohanguo/p/9045391.html
linux7安装MYSQL5.7
1、下载并安装MySQL官方的 Yum Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
2、安装MYSQL5.7
yum -y install mysql-community-server
yum -y install mysql-community-server --nogpgcheck
3、启动初始化MYSQL
systemctl start mysqld.service
systemctl enable mysqld.service
systemctl status mysqld.service
4、修改密码
grep "password" /var/log/mysqld.log --查询初始密码
[root@localhost opt]# grep "password" /var/log/mysqld.log
2019-08-26T01:16:14.421089Z 1 [Note] A temporary password is generated for root@localhost: qm?R.y6%ao&n
[root@localhost opt]# mysql -uroot -p
Enter password:
mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Passw0rd!';
mysql> update mysql.user set authentication_string=password('Passw0rd!') where user='root' ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 1
mysql> update mysql.user set authentication_string=password('Passw0rd!') where user='root' ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 1
mysql> grant all privileges on *.* to root@'%' identified by "Passw0rd!";
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
CREATE DATABASE IF NOT EXISTS cg DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON cg.* TO cg@'%' IDENTIFIED BY 'Passw0rd!';
FLUSH PRIVILEGES;
CREATE DATABASE IF NOT EXISTS control DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON control.* TO control@'%' IDENTIFIED BY 'Passw0rd!';
FLUSH PRIVILEGES;
CREATE DATABASE IF NOT EXISTS jira DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON jira.* TO jira@'%' IDENTIFIED BY 'Passw0rd!';
FLUSH PRIVILEGES;
CREATE DATABASE IF NOT EXISTS terminal_monitor DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON terminal_monitor.* TO terminal_monitor@'%' IDENTIFIED BY 'Passw0rd!';
FLUSH PRIVILEGES;
The error means mysqld does not have the access rights to the directory.
setenforce 0
cat /etc/selinux/config
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Passw0rd!';
update mysql.user set authentication_string=password('Passw0rd!') where user='root' ;
grant all privileges on *.* to root@'%' identified by "Passw0rd!";
flush privileges;