zoukankan      html  css  js  c++  java
  • 13.1 设置更改root密码 13.2 连接mysql 13.3 mysql常用命令

     

    检查mysql服务有没有启动,已经启动啦

    这条命令并没有在环境路径里面

    [root@lizhipenglinux01 ~]# echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

    [root@lizhipenglinux01 ~]# export PATH=$PATH:/usr/local/mysql/bin/   把命令添加到路径里面,但是并没有永久生效。想要永久生效,要把该语句放到/etc/profile下面

    [root@lizhipenglinux01 ~]# source /etc/profile   生效

    -u指定用户,-p指定密码

    [root@lizhipenglinux01 ~]# mysqladmin -uroot password 'aminglinux.1'           设置root密码
    Warning: Using a password on the command line interface can be insecure.
    [root@lizhipenglinux01 ~]# mysql -uroot                                                            没有密码-p会报错
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    [root@lizhipenglinux01 ~]# mysql -uroot -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 5
    Server version: 5.6.36 MySQL Community Server (GPL)

    Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

    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>

    那么如何更改密码呢(在已知root密码的条件下)

    如果忘记root密码,那该如何操作

    1.更改配置文件,增加skip-grant,忽略授权

    2.重启mysql

    可以直接登录进来

    3更改user表,更新密码

    4.把之前的配置my.cnf再改回来,并重启服务

     

    后面的-P用来指定远程主机MySQL的绑定端口,默认是3306,-h用来指定远程主机的IP

    利用socket连接mysql,不是用的tcp/ip,这种方式只适合在本机

     

    连接的时候执行sql语句

    查看表里的字段

    mysql> show create table userG; 看表是怎么建的

    查看所使用的database

    创建数据库db1

    查看当前版本

    查看队列

  • 相关阅读:
    子程序的设计
    多重循环程序设计
    汇编语言的分支程序设计与循环程序设计
    代码调试之串口调试2
    毕昇杯模块之光照强度传感器
    毕昇杯之温湿度采集模块
    【CSS】盒子模型 之 IE 与W3C的盒子模型对比
    【css】盒子模型 之 概述
    【css】盒子模型 之 弹性盒模型
    【网络】dns_probe_finished_nxdomain 错误
  • 原文地址:https://www.cnblogs.com/sisul/p/8592963.html
Copyright © 2011-2022 走看看