13.1 設定更改root密碼 13.2 串連mysql 13.3 mysql常用命令

來源:互聯網
上載者:User

標籤:alt   denied   com   soc   spec   glin   生效   分享圖片   pass   

 

 

檢查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

查看目前的版本

查看隊列

 

13.1 設定更改root密碼 13.2 串連mysql 13.3 mysql常用命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.