hmysql5.7安装请参考
https://blog.csdn.net/qq_34962337/article/details/82353082
1,mysql关闭的几种方法
mysqladmin -u root -p shutdown --mysqladmin关闭mysql
/etc/init.d/mysqld stop --mysqld脚本关闭
systemctl stop mysqld --mysql脚本关闭
kill -9 进程 --先查看mysqld进程,但不推荐方法
2,mysql修改密码
1
alter user root@'localhost' identified by '654321';
flush privileges;
2
mysqladmin -u root -p password 123456
3
mysql> use mysql
mysql> update mysql.user set authentication_string=password('6543216') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
4
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('7654321');
mysql> flush privileges;
5
忘记root密码,修root修改密码
/etc/init.d/mysqld stop --关闭mysql
mysqld_safe --skip-grant-tables & --安全模式启动
mysql> use mysql
mysql> update mysql.user set authentication_string=password('6543216') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
/etc/init.d/mysqld restart --重启mysql
3,mysql基础语法
1,mysql添加普通用户
mysql> create user 'test'@'localhost' identified by '123456';
mysql> flush privileges;
mysql> grant select on *.* to 'test2'@'localhost' identified by '654321';
mysql> flush privileges;
2
授权mysql用户和回收权限
mysql> grant select,insert on mydb.* to 'test'@'localhost';
mysql> show grants for 'test'@'localhost'; --查看权限
mysql> revoke