MYSQL数据库安装记

这回安装数据库装,做下记录。

1、下载mysql源安装包

shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

2、安装mysql源

shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm

3、检查mysql源是否安装成功

shell> yum repolist enabled | grep "mysql.*-community.*"

4、安装MYSQL

shell> yum install mysql-community-server

5、启动MYSQL服务

shell> systemctl start mysqld

6、设置开机启动

shell> systemctl enable mysqld
shell> systemctl daemon-reload

7、查看MYSQL临时密码

shell> grep 'temporary password' /var/log/mysqld.log

8、修改MYSQL默认密码

shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; 
或
mysql> set password for 'root'@'localhost'=password('MyNewPass4!'); 

9、添加远程登陆用户

mysql> GRANT ALL PRIVILEGES ON *.* TO 'yangxin'@'%' IDENTIFIED BY 'Yangxin0917!' WITH GRANT OPTION;

10、配置默认编码为UTF-8

[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'

11、开启防火墙

firewall-cmd --add-port=3306/tcp --permanent

之前MYSQL配置好了,但是无法远程登陆,发现系统中没有IPtable。其实CentOS7 中是firewall,需要上面的命令才能开启MYSQL 3306端口。

原文地址:https://www.cnblogs.com/MiWhite/p/6442651.html