• MySql命令的基本操作


    MySQL的基本命令:

    登录:mysql  -h -u root -p

            password:*****;

    例如:mysql -h127.0.0.1 -uroot -p

    增加一个用户: grant all on databasename.tableName to username@localhost identified by 'password';

    增加一个本地用户:insert into mysql.user(Host,User,Password) values("Tonge","test",password("a123"));

    增加一个远程用户:grant all privileges on*.* to Tonge@"%" identified by 'a123';

    解释:grant all 数据库.表名 to 用户名@域 identified by '密码'

    查询所有数据库:show databases;

    使用数据库:use databaseName;

    查看所有表:show tables;

    查看表结构:show columns from 表名;

                         select * from columns where table_name='表名';

    mysql 忘记root密码:

    1.先停止mysql服务,使用第2步无验证方式启动:
    2.使用cmd进到mysql安装的bin目录执行:mysqld -nt --skip-grant-tables;
    3.新启动一个cmd,输入,mysql -uroot -p 回车;
    4.选择mysql数据库:use mysql;
    5.修改密码:update user set password=password("new_pass") where user="root";
    6.刷新权限:flush privileges;
    上面步骤如果出现拒绝访问,请尝试用管理员cmd命令窗重试。

    注意mysql5.7已经没有password字段了,改为了authentication_string

     update user set authentication_string=password("root") where user="root";

    mysql 8小时时间差

    mysql > SET time_zone = '+8:00';   # 此为我们所在东8区
    mysql> flush privileges;   # 立即生效
    

     或者

    mysql安装目录下my.cnf/my.ini的 [mysqld]下的第一行中加上

    default-time_zone = '+8:00'
  • 相关阅读:
    软件測试培训笔记
    spring test---測试SpringMvc初识
    第1章第3节 线性表的比較
    Remove Duplicates from Sorted List leetcode
    泛型
    我的改进版2048(1)
    docker镜像和加速
    在 Azure Web 应用中创建 PHP 应用程序
    使用 Azure 门户创建 Windows 虚拟机
    使用 Azure 门户创建 Linux 虚拟机
  • 原文地址:https://www.cnblogs.com/tonge/p/3522938.html
Copyright © 2020-2023  润新知