Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql 备忘 #45

Open
hsipeng opened this issue Mar 26, 2018 · 0 comments
Open

Mysql 备忘 #45

hsipeng opened this issue Mar 26, 2018 · 0 comments
Labels

Comments

@hsipeng
Copy link
Owner

hsipeng commented Mar 26, 2018

mysql

#mysql

抓取 MySQL Table auto_increment 的最大值

直接由 information_schema 找 MySQL Table auto_increment 的最大值, 有下述兩種情況:

  • 此 Table name 於整個 MySQL DB 中是唯一的:
SELECT TABLE_ROWS FROM information_schema.tables WHERE table_name='YOUR_TABLE_NAME';
  • 此 Table name 於整個 MySQL DB 中有多個, 需要指定 DB Name:
SELECT TABLE_ROWS FROM information_schema.tables WHERE table_name='YOUR_TABLE_NAME' AND table_schema = 'YOUR_DB_NAME';

或下述:
use YOUR_DB_NAME; // 抓取自己現在的 Database name 可用: SELECT DATABASE();

SELECT TABLE_ROWS FROM information_schema.tables WHERE table_name='YOUR_TABLE_NAME' AND table_schema = DATABASE();

开启权限

开启远程访问权限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY ‘!123456’ WITH GRANT OPTION;

// 刷新权限
FLUSH PRIVILEGES;
@hsipeng hsipeng added the mysql label Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant