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

    查看当前版本

    查看队列

  • 相关阅读:
    学习JavaScript 的必备 (一),让您对js的 function, javascript内置对象,this概念及之间的关系不再迷惑。(希望能置为推荐篇,为更多的js初学者关注)
    你人脉网中应该有的10种人
    十句话,不黄不色,但很经典~~~~~~~~~~
    js网站
    …↓爆》笑
    JavaScript使用技巧精萃
    JDK源码分析之Set类详解——适配器模式的应用
    好的程序员做不出好的软件设计
    JDK源码中ClassLoader的浅析
    提高编程技巧的十大方法
  • 原文地址:https://www.cnblogs.com/sisul/p/8592963.html
Copyright © 2011-2022 走看看