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 user\G; 看表是怎麽建的
查看所使用的database
創建數據庫db1
查看當前版本
查看隊列
13.1 設置更改root密碼 13.2 連接mysql 13.3 mysql常用命令