百度
360搜索
搜狗搜索

linux用户如何登录mysql详细介绍

Linux 用户若要登录 MySQL,可按以下步骤操作:

一、确认 MySQL 服务已启动

你可以通过下面的命令来检查 MySQL 服务的运行状态:
bash

 systemctl status mysql

若服务未启动,可使用以下命令启动它:
bash

 systemctl start mysql

二、使用 root 用户登录

在终端里输入如下命令,然后依据提示输入 root 用户的密码:
bash

mysql  root 

若你是初次安装 MySQL,可能需要先重置 root 密码:
bash

 mysql  root

进入 MySQL 后,执行以下命令来修改 root 用户的密码:
sql

   IDENTIFIED  mysql_native_password  

FLUSH

三、使用普通用户登录

如果你已经创建了普通用户,可使用以下命令登录:
bash

mysql  用户名 

四、常见登录问题解决办法

  • 无法远程登录:要确认 MySQL 配置文件(通常是/etc/mysql/mysql.conf.d/mysqld.cnf)中是否注释掉了bind-address = 127.0.0.1
  • 权限不足:可以使用 root 用户为普通用户授权,例如:sql
        数据库名  

    FLUSH

五、验证登录情况

登录成功后,你会看到类似下面的提示符:
plaintext

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 12345

Server version: 8.0.26 MySQL Community Server - GPL

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




991234567891011121314Welcome to the MySQL monitor. Commands end with ; or .Your MySQL connection id is 12345Server version: 8.0.26 MySQL Community Server - GPL

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

Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.

Type 'help;' or '' for help. Type '' to clear the current input statement.

mysql>

现在,你就可以执行 SQL 命令来管理数据库了。

阅读更多 >>>  linux挂载命令实例

文章数据信息:

本文主要探讨:"linux用户如何登录mysql", 浏览人数已经达到28次, 首屏加载时间:0.912 秒。