赞
踩
下载页面:https://dev.mysql.com/downloads/mysql
MySql 5.7下载链接 :
https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.25-winx64.zip
http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
MySql8.0下载链接 :
https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.15-winx64.zip
再给个国内镜像
http://mirrors.ustc.edu.cn/mysql-ftp/Downloads
D:\mysql5.7
或 D:\mysql8.0
如果本机只安装一个版本就直接用 D:\mysql
D:\mysql\bin
路径追加进环境变量 path
D:\mysql\data
(有人又说不要创建,让mysql初始化时自动生成)D:\mysql\my.ini
从MySQL 5.7.18开始,不再自带这个文件,自己创建就行了# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir=d:\mysql
datadir=d:\mysql\data
# port = .....
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
# sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
参考
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=d:\\mysql
datadir=d:\\mysql\\data
# 允许最大连接数
max_connections=200
# 允许最大连接人数
max_user_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
管理员
身份运行cmd# 进入 D 盘
C:\Users\Administrator>d:
# 进入mysql的bin 目录
D:\>cd mysql/bin
# 初始化.
# --initialize 随机密码
# --initialize-insecure 无密码
# --user指定所属用户
D:\mysql\bin>mysqld --initialize-insecure --user=mysql
# 安装:默认的服务名是 mysql
D:\mysql\bin> mysqld install
# 启动 mysql
D:\mysql\bin>net start mysql
删除服务
# 关闭服务
net start mysql
# 删除服务
mysqld -remove mysql
在已经装了 mysql5.7
后,再装 mysql8.x
到 D:\mysql-8.0.31-winx64
记得使用绝对路径。
# 这次 mysqld 用了绝对路径
D:\>D:\mysql-8.0.31-winx64\bin\mysqld --initialize-insecure --user=mysql
# 安装:
# 默认的服务名是 mysql
# 如果同时装多个MySQL,会需要手动指定服务名。比如 MySQL8。
# 指定配置文件 --defaults-file=D:\mysql-8.0.31-winx64\my.ini
D:\>D:\mysql-8.0.31-winx64\bin\mysqld install MySQL8
# 启动 mysql
D:\mysql\bin>net start mysql8
可能装好后会发现还是 5.7x
的路径。
mysql -u 用户名 -p密码 [数据库名]
update user set password=password(“新密码”) where user=”用户名”;
use mysql # 选择数据库
# 修改密码(密码)
update mysql.user set authentication_string=PASSWORD('123456') where User='root';// root密码改为123456
update mysql.user set authentication_string=password('root') where user='root';// root密码改为root
flush privileges; #刷新
mysql
服务:net stop mysql
MySQL
安装路径下:D:\mysql-5.7.16-winx64\bin
mysqld -nt --skip-grant-tables
管理员cmd
输入:mysql -uroot -p
回车,密码不用填回车,即可进入数据库。环境 | 描述 |
---|---|
操作系统 | CentOS7 64位 |
MySQL | MySQL5.7 |
在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo/yum/
# 下载mysql源安装包
[jerryjin@localhost 下载]$ wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# 安装mysql源
[jerryjin@localhost 下载]$ sudo yum localinstall mysql57-community-release-el7-8.noarch.rpm
# 检查mysql源是否安装成功
[jerryjin@localhost 下载]$ yum repolist enabled | grep "mysql.*-community.*"
成功显示如下:
mysql-connectors-community/x86_64 MySQL Connectors Community 108
mysql-tools-community/x86_64 MySQL Tools Community 90
mysql57-community/x86_64 MySQL 5.7 Community Server 347
我们要安装 mysql5.7 检查一下
[jerryjin@localhost 下载]$ cat /etc/yum.repos.d/mysql-community.repo
看到 [mysql57-community]
下enabled=1
其他版本enabled=0
正合我意,不用改了。如果不是我们vim
进去改一改
[jerryjin@localhost 下载]$ sudo yum install mysql-community-server
...
# 一通跑后列出我要下载 194M 的东西。输入y回车即可。
Total download size: 194 M
Is this ok [y/d/N]: y
# 下载完后 Retrieving key 还会问一次,我不懂。输入y回车继续
# 然后就是一通安装的信息,最后就成功了
重新导入秘钥
[jerryjin@localhost 下载]$ rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
然后再执行 安装命令即可
[jerryjin@localhost 下载]$ sudo yum install mysql-community-server
[jerryjin@localhost 下载]$ systemctl start mysqld
查看状态。
[jerryjin@localhost 下载]$ systemctl status mysqld
能看到绿色的 active (running) 表示成功
[jerryjin@localhost 下载]$ systemctl enable mysqld
[jerryjin@localhost 下载]$ systemctl daemon-reload
初始生成的默认密码记录在/var/log/mysqld.log
。我们找出来:
[jerryjin@localhost 下载]$ grep 'temporary password' /var/log/mysqld.log
登录 MySQL
[jerryjin@localhost 下载]$ mysql -uroot -py>kjl5&Qwq_m
目前远程登录还没实现,以下是在本机上操作:
validate_password = off
[jerryjin@localhost 下载]$ sudo vim /etc/my.cnf
重启mysql
生效
[jerryjin@localhost 下载]$ systemctl restart mysqld
root
密码为root
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root'
mysql
默认只允许root
帐户在本地
登录,如果要在其它机器上连接mysql,要么修改root允许远程连接。接下来我必须去本机操作了23333
mysql> select user,host from mysql.user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-----------+
没修改默认密码前做以下操作,系统会提示你先改密码。
%
表示允许所有机器访问,可以替换成ip
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
mysql> select user,host from mysql.user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| root | % |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-----------+
成功后就可以远程登录了
[jerryjin@localhost 下载]$ mysql -h 192.168.31.37 -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> GRANT ALL PRIVILEGES ON *.* TO 'jerryjin'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.32 sec)
mysql> select user,host from mysql.user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| jerryjin | % |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-----------+
两种方法查看:
mysql> status;
mysql> show variables like’char%’;
配置文件 /etc/my.cnf
添加
mysql 中的一个坑 utf8mb4
才是真utf8
。详细介绍看:MySQL 的 utf8 和 utf8mb4 请使用 utf8mb4
[client]
default_character_set=utf8mb4
[mysqld]
collation_server = utf8_general_ci
character_set_server = utf8mb4
重启mysql
生效
[jerryjin@localhost 下载]$ systemctl restart mysqld
官网文档 9.2.3 Identifier Case Sensitivity
0
表名按原大小写存,读的时候区分大小写
1
表名按小写存,读时按小写取(忽略大小写了
)
2
表名按原大小写存,但是读的时候都自动转小写再用
如果已经有表存在,直接改这个会启动不了,因为之前的表会无法识别。可以先全导出,改后重启,再导入。
[mysqld]
lower_case_table_names=1
[client]
default_character_set=utf8
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
validate_password = off
collation_server = utf8_general_ci
character_set_server = utf8
# 1. 查看 3306 是否在工作
netstat -ntulp | grep 3306
# tcp6 0 0 :::3306 :::* LISTEN 28182/mysqld
# 2. 查看防火墙已经开放的端口
firewall-cmd --list-ports
# 3. 防火墙开放 3306 端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
# 4. 重启防火墙生效
firewall-cmd --reload
mysql> show global variables like 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set, 1 warning (0.01 sec)
MySQL5.7安装与配置(YUM)
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
linux centos7下源码 tar安装mysql5.7.22或mysql5.7.20 图文详解
MySQL 安装 | 菜鸟教程
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。