WSL2 Ubuntu : MySQL 安装记录

版本环境

WSL信息:

WSL 版本: 2.3.26.0
内核版本: 5.15.167.4-1
WSLg 版本: 1.0.65
MSRDC 版本: 1.2.5620
Direct3D 版本: 1.611.1-81528511
DXCore 版本: 10.0.26100.1-240331-1435.ge-release
Windows 版本: 10.0.22631.5039

Ubuntu版本:
Ubuntu 24.04.1 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)

MySQL版本:
Server version: 8.0.41-0ubuntu0.24.04.1 (Ubuntu)

安装步骤

1. 更新apt软件包

sudo apt update

2. 安装Mysql

sudo apt install mysql-server -y

3. 启用Mysql服务

sudo service mysql start

可以使用以下命令检查是否成功启用。

sudo service mysql status

成功启用的输出示例,注意看Loaded和Active信息。

● mysql.service - MySQL Community Server
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: active (running) since Mon 2025-03-17 00:22:36 CST; 1min 49s ago
    Process: 1513 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 1521 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 9361)
     Memory: 358.7M ()
     CGroup: /system.slice/mysql.service
             └─1521 /usr/sbin/mysqld

4. 查看Mysql初始密码

sudo cat /etc/mysql/debian.cnf

示例输出:

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = example
password = example
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = example
password = example
socket   = /var/run/mysqld/mysqld.sock

记住用户名(user)和密码(password),等下登录要用。

5. 修改Mysql中root用户密码

使用你刚刚记住的用户名和密码登录MySQL,输入密码进入MySQL终端

mysql -uexample -p

按照如下指令顺序输入:

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
Query OK, 0 rows affected (0.01 sec)

到这里MySQL的基本安装步骤就完成了,后续的配置按照正常MySQL配置即可。

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇