mysql基本功

Tags:

install

apt install mysql-server

set up

sudo mysql_secure_installation utility

start & enable

sudo systemctl start mysql
sudo systemctl enable mysql

mysql

/usr/bin/mysql -u root -p
#root是用户名,输入这条命令按回车键后系统会提示你输入密码

change passwd

UPDATE mysql.user SET authentication_string = PASSWORD(‘password’) WHERE User = ‘root’;

view users

SELECT User, Host, authentication_string FROM mysql.user;

new db, db user

CREATE DATABASE demodb;
create user [email protected] identified by ‘demopassword’;

GRANT ALL PRIVILEGES ON demodb.* to [email protected];
# 如果是对于任意IP都允许 - 用 %
GRANT SELECT,INSERT,UPDATE,DELETE ON guaca.* TO 'guaca'@'%';

SHOW GRANTS FOR 'demouser'@'localhost';

allow taking effect

FLUSH PRIVILEGES;

1 thought on “mysql基本功”

  1. Pingback: 在VPS上安装Nextcloud – 1024 & 4201

Leave a Reply