install
Shell
x
1
1
apt install mysql-server
set up
Shell
xxxxxxxxxx
1
1
1
sudo mysql_secure_installation utility
start & enable
Shell
xxxxxxxxxx
1
2
1
sudo systemctl start mysql
2
sudo systemctl enable mysql
mysql
Shell
xxxxxxxxxx
1
4
1
/usr/bin/mysql -u root -p
2
#root是用户名,输入这条命令按回车键后系统会提示你输入密码
3
4
mysql -u root -p'password' -h remote.mysqlsqlserver.com -P 59066 -D DatabaseName
change passwd
Shell
xxxxxxxxxx
1
1
1
UPDATE mysql.user SET authentication_string = PASSWORD('password') WHERE User = 'root';
view users
Shell
xxxxxxxxxx
1
1
1
SELECT User, Host, authentication_string FROM mysql.user;
new db, db user
Shell
xxxxxxxxxx
1
2
1
CREATE DATABASE demodb;
2
create user demouser@localhost identified by 'demopassword';
Shell
xxxxxxxxxx
1
5
1
GRANT ALL PRIVILEGES ON demodb.* to demouser@localhost;
2
# 如果是对于任意IP都允许 - 用 %
3
GRANT SELECT,INSERT,UPDATE,DELETE ON guaca.* TO 'guaca'@'%';
4
5
SHOW GRANTS FOR 'demouser'@'localhost';
allow taking effect
Shell
xxxxxxxxxx
1
1
1
FLUSH PRIVILEGES;