補覺鳴詩

學海無涯


  • 首頁

  • archive

  • 關於我

  • 搜尋

mysql 指令紀錄

時間: 0001-01-01   |   分類: mysql   | 字數: 237 字 | 閱讀: 1分鐘 | 閱讀次數:

紀錄 mysql 操作

sql-server.jpg

# login

mysql -u root
mysql -u foouser -p  

# list DB
show databases;

# reset
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -u root
use mysql;
update user set password=password('123') where user='root' and host='localhost';
quit;

# 改回不用密碼登錄
mysqladmin -u root -p'oldpassword' password ''

# 改密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'P@ssw0rd';

## mysql 升級
/var/lib/mysql 蓋掉
有需要的話,重設 root 密碼 
mysql_upgrade -u root -p

PHP 連線 mysql 須帶入 socket 參數

[root@node3 ~]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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> status;
--------------
mysql  Ver 8.0.26 for Linux on x86_64 (Source distribution)

Connection id:          8
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         8.0.26 Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:            /var/lib/mysql/mysql.sock
Binary data as:         Hexadecimal
Uptime:                 1 min 16 sec

php

#mysql#
comments powered by Disqus >
  • 文章目錄
  • 網站導覽
Owan

Owan

愛貓如癡

131 日誌
29 分類
37 標籤
GitHub
© 2010 - 2022 補覺鳴詩
Powered by - Hugo v0.96.0 / Theme by - NexT
0%