涛声依旧在 发表于 2025-3-29 16:16:17

MySQL的安装和配置

MySQL的安装和配置

针对差异的操作系统,根据上面的情况,来选择对应的版本。
window操作系统安装

存在两种安装方式:

[*]安装包方式
[*]压缩包方式
安装包方式

没有什么特别的地方,下载安装包。下一步、下一步,直至竣事。
在此过程中,注意一些选择标题。
安装方式如下:
1、下载安装包
官网下载对应的安装包,根据必要下载对应的版本即可:
8.0:https://cdn.mysql.com//Downloads/MySQLInstaller/mysql-installer-community-8.0.18.0.msi
5.7:https://cdn.mysql.com//Downloads/MySQLInstaller/mysql-installer-community-5.7.28.0.msi
固然也可以选择自己必要的版本:https://downloads.mysql.com/archives/installer/
2、安装过程
https://i-blog.csdnimg.cn/img_convert/ccc0cc7f043469dabb52e0cdfc4b1278.png
https://i-blog.csdnimg.cn/img_convert/d30f1940f25f1fcafa1c244d77fa7f57.png
https://i-blog.csdnimg.cn/img_convert/d256752ade3519fafbf514103c21dde3.png
https://i-blog.csdnimg.cn/img_convert/adbab4c270891166c86368a64bd01e45.png
https://i-blog.csdnimg.cn/img_convert/470a9e6e90907013eb283f2d1673751b.png
https://i-blog.csdnimg.cn/img_convert/94e9c225e3a98c7b1ebe16193911e7f9.png
https://i-blog.csdnimg.cn/img_convert/1e09d71af43ee970f222e138386a87d4.png
https://i-blog.csdnimg.cn/img_convert/11c648ec1ccbf6ed060d92d9c019c2ec.png
https://i-blog.csdnimg.cn/img_convert/4b4aee245997059109822b616f919d8b.png
https://i-blog.csdnimg.cn/img_convert/a40811944645d544b9601bc414fe5037.png https://i-blog.csdnimg.cn/img_convert/eaf62db34eb5eb3fd76272756fa18cbb.png
https://i-blog.csdnimg.cn/img_convert/26a7dbaba1ec2f35d66d93f7a1197d15.png
https://i-blog.csdnimg.cn/img_convert/8dd3cd9bd7a493bc7c408f410f96a57f.png
https://i-blog.csdnimg.cn/img_convert/63558baecdf45b92f2f6c73a965aac3e.png
安装包的方式比较简单,安装提示对应的完成操作即可(差异的版本可能有所区别,但是都大同小异),这种方式适合于新手使用,一般开发者都建议使用压缩包的方式完成。
压缩包方式

推荐大家使用这种方式

[*] 下载位置:mysql下载位置
[*] 解压缩后位置:D:\mysql-8.0.15-winx64
[*] 在主目录下复制、创建一个xx.ini,修改为my.ini,修改此中的basedir和datadir
​ basedir=mysql主目录
​ datadir=mysql主目录/data
[*] 配置bin目录为情况变量
方便在终端情况下,查找MySQL的相干下令
⚠️ 注意:一定要重新启动CMD
[*] 初始化下令(记录控制台给出的随秘密码,一定记着):
⚠️ 一定要注意:打开cmd时,必须使用管理员身份!!!cmd打开后,切换到bin目录再执行如下下令
mysqld --initialize --console
[*] 然后先给mysql服务创建名称(方便到时间创建多个mysql服务时不冲突)
mysqld --install mysql8
[*] 启动服务:
net start mysql
[*] 登岸旧密码登岸(第3步中的密码):
mysql -u root -p
[*] 修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
                                  
# 之后键入修改密码的命令:
ALTER USER root@localhost IDENTIFIEDBY 'root';

[*] 使用新密码登岸:
mysql -u root -p 新密码
卸载MySQL:
​ 停止服务:net stop mysql
​ 删除服务:mysqld --remove
登录成功后,执行下令:
show databases;
MySQL的配置文件(window版——my.ini):

# skip_grant_tables
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\dev_soft\mysql-8.0.20-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\dev_soft\mysql-8.0.20-winx64\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB


#password = your_password
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4


# 设置mysql客户端默认字符集
default-character-set=utf8mb4
使用客户端登录MySQL服务器

cmd输入如下下令:
mysql --uroot --p
mysql -h127.0.0.1 -P3306 -uroot -p
查看安装的MySQL版本:
mysql -V
使用帮助下令查看MySQL终端下令:
mysql> \h

For information about MySQL products and services, visit:
   http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
   http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
   https://shop.mysql.com/

List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear   (\c) Clear the current input statement.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go      (\g) Send command to mysql server.
help      (\h) Display this help.
notee   (\t) Don't write into outfile.
print   (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile . Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings(\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
resetconnection(\x) Clean session context.

For server side help, type 'help contents'

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: MySQL的安装和配置