1. 程式人生 > >13.1 設置更改root密碼 13.2 連接mysql 13.3 mysql常用命令

13.1 設置更改root密碼 13.2 連接mysql 13.3 mysql常用命令

mysq 常用 版本 Owner 端口 acc pat CP 更改root密碼

技術分享圖片

技術分享圖片

檢查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常用命令