centos7下面的mysql5.7安装步骤

1、下载 MySQL 源的安装包
	wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
2、安装 MySql 源
	yum -y install mysql57-community-release-el7-11.noarch.rpm
3、yum 安装 mysql 启动 MySQL 服务
	1、安装 mysql(很慢很慢很慢)
		yum -y install mysql-server
	2、启动 MySQL
		systemctl start mysqld
	3、查看 MySQL 的启动状态
		systemctl status mysqld
	4、配置 MySQL 服务开机启动
		systemctl enable mysqld
	5、配置 MySQL 服密码策略
		共有以下几种密码策略:
			策略 检查规则 0 or LOW Length 1 or MEDIUM Length; numeric, lowercase/uppercase, and special
			characters 2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file
			MySQL 官网密码策略详细说明:
			http://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html#sysvar_validate_pas
			sword_policy
			修改密码策略 在/etc/my.cnf 文件添加 validate_password_policy 配置,指定密码策略
			选择 0(LOW),1(MEDIUM),2(STRONG)其中一种,选择 2 需要提供密码字典文件
			> validate_password_policy=0
			如果不需要密码策略,添加 my.cnf 文件中添加如下配置禁用即可:
			> validate_password = off
			重新启动 mysql 服务使配置生效:
			> systemctl restart mysqld
	6、修改 MySQL root 本地登录密码
		mysql 安装完成之后,在/var/log/mysqld.log 文件中给 root 生成了一个默认密码。通过下面的方式找到 root 默认密码,然后登录 mysql 进行修改
		grep 'temporary password' /var/log/mysqld.log #查看密码
		mysql -uroot -p #登录mysql
		set password for 'root'@'localhost'=password('Bb123456!');
	7、添加 mysql 远程登录用户
		mysql -u root -p
		mysql> use mysql;
		mysql> update user set host = '%' where user = 'root';
		mysql> select host, user from user; 
	8、配置防火墙
		firewall-cmd --zone=public --add-port=3306/tcp --permanent
		firewall-cmd --reload
	9、配置默认编码为 utf8
		修改/etc/my.cnf 配置文件
		在[mysqld]下面加入如下配置
		character_set_server=utf8
		init_connect=‘SET NAMES utf8’
	10、重新启动 mysql 服务
		systemctl restart mysqld
	11、常用命令	
		systemctl mysqld start  #运行
		systemctl mysqld stop #停止
		systemctl enable mysqld  # 开机自启动
		systemctl status mysqld #状态

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章