在Ubuntu上安装MySQL 8
糊涂粥 于 2024-06-12 16:36:51

服务器使用的是 腾讯云 的 轻量服务器,Ubuntu Server 20.04 LTS 64bit,2核4GB,60GBSSD,5Mbps。

一、在安装之前,请先对 Ubuntu 系统进行更新

sudo apt update && sudo apt upgrade

二、使用Ubuntu 官方源进行安装

sudo apt install mysql-server -y

三、安装成功后进入mysql控制台,使用系统root权限进入控制台不需要密码

lighthouse@VM-24-15-ubuntu:~$ sudo mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.37-0ubuntu0.20.04.3 (Ubuntu)

Copyright (c) 2000, 2024, 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> 

四、添加一个新的管理员用户

1、创建用户

mysql> create user 'manager'@'localhost' identified with mysql_native_password by '12345678';

2、赋予权限

mysql> grant all on *.* to 'manager'@'localhost' with grant option;

3、刷新权限

mysql> flush privileges;

4、退出mysql

mysql> quit
Bye

至此安装完成,可以使用phpMyAdmin等mysql管理软件使用新创建的用户登录进行管理操作了。

enjoy

阅读 (793)