Skip to content

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是用户名,输入这条命令按回车键后系统会提示你输入密码

mysql -u root -p'password' -h remote.mysqlsqlserver.com -P 59066 -D DatabaseName

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 demouser@localhost identified by 'demopassword';
GRANT ALL PRIVILEGES ON demodb.* to demouser@localhost;
# 如果是对于任意IP都允许 - 用 %
GRANT SELECT,INSERT,UPDATE,DELETE ON guaca.* TO 'guaca'@'%';

SHOW GRANTS FOR 'demouser'@'localhost';

allow taking effect

FLUSH PRIVILEGES;

Leave a Reply

Your email address will not be published.