mysql 5.7.20 安装_Mysql5.7.20安装,Mysql8.0安装

一、Windows版:zip方式

1、下载zip包

https://dev.mysql.com/downloads/mysql/

https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.20-winx64.zip

解压到 D:\Program Files\mysql-5.7.20-winx64

2、在bin同级目录,新建my.ini文件

D:\Program Files\mysql-5.7.20-winx64\my.ini

[mysql]

default-character-set=utf8

[mysqld]

port=3306

basedir="D:/Program Files/mysql-5.7.20-winx64/"

datadir="D:/Program Files/mysql-5.7.20-winx64/data"

character-set-server=utf8

default-storage-engine=INNODB

max_connections=100

3、以管理员身份运行cmd,在bin目录执行:

..\bin> .\mysqld --initialize-insecure --user=mysql

..\bin> .\mysqld install

4、连接mysql

..\bin> .\mysql -uroot -p

5、修改密码

..\bin> mysqladmin -u root password root

mysql> set password=password('root')

6、启动停止

cmd> net stop mysql

cmd> net start mysql

二、Linux版(centos7.2):yum方式

1、安装yum源

mysql官网yum源

http://dev.mysql.com/downloads/repo/yum/

下载yum源

shell> wget -c https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

安装yum源

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

检查yum源

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

修改mysql yum源

shell> vim /etc/yum.repos.d/mysql-community.repo

8.0版本

shell> wget -c https://repo.mysql.com/mysql80-community-release-el7-2.noarch.rpm

shell> yum localinstall mysql80-community-release-el7-2.noarch.rpm

2、安装mysql

shell> yum install mysql-community-server

3、启动mysql

shell> systemctl start mysqld

查看启动状态

shell> systemctl status mysqld

4、设置开机启动

shell> systemctl enable mysqld

shell> systemctl daemon-reload

5、修改密码

查看默认密码

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

连接mysql

shell> mysql -uroot -p

修改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass2!';

mysql> set password for 'root'@'localhost'=password('MyNewPass2!');

6、添加远程登录用户

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

7、配置默认编码

shell> vi /etc/my.cnf

[mysqld]

character_set_server=utf8

init_connect='SET NAMES utf8'

8、重启mysql

shell> service mysqld restart

9、默认配置文件路径

配置文件:/etc/my.cnf

日志文件:/var/log/mysqld.log

服务启动脚本:/usr/lib/systemd/system/mysqld.service

socket文件:/var/run/mysqld/mysqld.pid

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值