MySQL8常用命令:
一.Mysql8 启动,停止以及重启操作命令
启动mysql:
>service mysqld start
脚本启动:/etc/inint.d/mysqld start
查看mysql状态
>service mysqld status
重启mysql
>service mysqld restart
脚本重启:/etc/inint.d/mysqld restart
停止mysql
>service mysqld stop
脚本停止:/etc/inint.d/mysqld stop
二.登陆mysql
>mysql -uroot -p
修改新密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Hu12345@';
#创建远程访问%用户
需要将mysql用户登录的加密规则修改为mysql_native_password。
mysql> create user myuser@'%' identified by 'Hu12345@';
Query OK, 0 rows affected (0.01 sec)
mysql> ALTER USER 'myuser'@'%' IDENTIFIED BY 'Hu12345@' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.28 sec)
mysql> ALTER USER 'myuser'@'%' IDENTIFIED WITH mysql_native_password BY 'Hu12345@';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
(原因:navicat链接mysql8以后的版本时,会出现2059的错误,这个错误出现的原因是在mysql8之前的版本中加密规则为mysql_native_password,而在mysql8以后的加密规则为caching_sha2_password。)
授权用户:
Mysql>grant all privileges on *.* to myuser;
其他命令:
#显示数据库
mysql> show databases;
#创建数据库
mysql> create database mysqltest;
#进入数据库mysqltest
use mysqltest;
#显示表
show tables ;
-----------------------
#查询用户
SELECT user, host FROM mysql.user;
#授权
grant all privileges on *.* to myuser;