检查mysql服务有没有启动,已经启动啦
这条命令并没有在环境路径里面
[[email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[[email protected] ~]# export PATH=$PATH:/usr/local/mysql/bin/ 把命令添加到路径里面,但是并没有永久生效。想要永久生效,要把该语句放到/etc/profile下面
[[email protected] ~]# source /etc/profile 生效
-u指定用户,-p指定密码
[[email protected] ~]# mysqladmin -uroot password ‘aminglinux.1‘ 设置root密码
Warning: Using a password on the command line interface can be insecure.
[[email protected] ~]# mysql -uroot 没有密码-p会报错
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
[[email protected] ~]# 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 user\G; 看表是怎么建的
查看所使用的database
创建数据库db1
查看当前版本
查看队列
原文地址:https://www.cnblogs.com/sisul/p/8592963.html