win11安装mysql8.0.29最新版

win11安装mysql8最新版

1、下载mysql

image-20220511141100914

2、解压

image-20220511141437289

3、初始化数据库并安装启动服务

以管理员身份打开CMD命令控制台

mysqld --initialize-insecure 初始化,会自动的在c:/dbs/mysql-8.0.29/data 建立目录

mysqld install 安装服务,服务名称为mysql

net start mysql

net stop mysql

net 是windows系统的服务管理命令

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sZizsAbd-1652251768811)(assets/image-20220511141937666.png)]

如果要通过窗口查看服务,在运行中可以输入services.msc 打开服务窗口

image-20220511141820605

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-LFRsKMah-1652251768812)(https://gitee.com/webrx/wx_note/raw/master/images/image-20220511142304677.png)]

4、登录服务器

C:\Users\webrx>cd \

C:\>cd dbs\mysql-8.0.29

C:\dbs\mysql-8.0.29>cd bin

#登录本机 -hlocalhost -uroot -p空没有密码 -P3306可以不写
C:\dbs\mysql-8.0.29\bin>mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.29 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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> select @@hostname,@@port,@@version,@@basedir,@@datadir,now();
+------------+--------+-----------+----------------------+---------------------------+---------------------+
| @@hostname | @@port | @@version | @@basedir            | @@datadir                 | now()               |
+------------+--------+-----------+----------------------+---------------------------+---------------------+
| wp         |   3306 | 8.0.29    | C:\dbs\mysql-8.0.29\ | C:\dbs\mysql-8.0.29\data\ | 2022-05-11 14:25:17 |
+------------+--------+-----------+----------------------+---------------------------+---------------------+
1 row in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.02 sec)

mysql> select host,user,plugin from mysql.user;
+-----------+------------------+-----------------------+
| host      | user             | plugin                |
+-----------+------------------+-----------------------+
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
| localhost | root             | caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)

mysql> create user admin identified with mysql_native_password by 'admin';
Query OK, 0 rows affected (0.01 sec)

mysql> grant all on *.* to admin;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> select host,user,plugin from mysql.user;
+-----------+------------------+-----------------------+
| host      | user             | plugin                |
+-----------+------------------+-----------------------+
| %         | admin            | mysql_native_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
| localhost | root             | caching_sha2_password |
+-----------+------------------+-----------------------+
5 rows in set (0.00 sec)

5、windows mysql 连接ubuntu docker mysql

C:\dbs\mysql-8.0.29\bin>mysql -h192.168.0.78 -uaa -p
Enter password: **
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 8.0.29 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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> select @@hostname,@@port,@@basedir,@@datadir;
+--------------+--------+-----------+-----------------+
| @@hostname   | @@port | @@basedir | @@datadir       |
+--------------+--------+-----------+-----------------+
| 661d0ece4131 |   3306 | /usr/     | /var/lib/mysql/ |
+--------------+--------+-----------+-----------------+
1 row in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql>

6、sqlyog 连接win mysql

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zqjT4PBi-1652251768812)(https://gitee.com/webrx/wx_note/raw/master/images/image-20220511143401417.png)]

image-20220511143516818

7、linux docker mysql 连接登录win mysql

docker run -it --rm mysql:8.0.29 mysql -h192.168.0.121 -uadmin -p

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Lmw02BLl-1652251768813)(https://gitee.com/webrx/wx_note/raw/master/images/image-20220511144350497.png)]

image-20220511144316337

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值