mysql常用命令

mysql

偶尔闲暇搞一搞数据库,自己搞数据库写接口,那是有多酷
当然首先你要安装mysql,这个网上都是有教程的。


1.启动

1
net start mysql

2.以管理员登录mysql

1
mysql -u root -p 123456

3. 显示所有数据库

进入mysql后,执行mysql命令以分号结束

1
show databases;

4. 选择数据库

1
use databaseName;

5. 创建数据库/表

1
2
create database databseName;
create table tableName;

6.显示数据库里的表

1
show tables

7. 删除数据库/表

1
2
drop database databseName;
drop table tableName;

8. 显示数据表的结构

1
describe tableName

9.将表中数据清空

1
delete from tableName

10.显示表中的记录

1
select * from tableName

11.关闭Mysqlserver服务

1
net stop mysql

在使用mysql之后,避免不了使用可视化工具,我这里使用了mysqlfront,版本6.1,但是版本打开不支持最新加密。
报错如下:MySQL-Front does not support passwords with Mysql8 and higher
不知道为什么,想要使用个新的东西总是困难重重,坑那么多,慢慢填。
The caching_sha2_password and sha256_password authentication plugins provide more secure password encryption than the mysql_native_password plugin, and caching_sha2_password provides better performance than sha256_password. Due to these superior security and performance characteristics of caching_sha2_password, it is as of MySQL 8.0 the preferred authentication plugin, and is also the default authentication plugin rather than mysql_native_password.
翻译过来就是:caching_sha2_password 和sha256_password认证插件比mysql_native_password插件提供的密码加密更加安全,并且caching_sha2_password加密比sha256_password的加密性能更好。由于caching_sha2_password这样优秀的安全和性能特性,让他作为MySQL8.0的首选认证插件,这也是默认的认证插件插件而不是mysql_native_password

经过查阅资料,原来mysql8.0默认使用了新的加密方式,大多数第三方工具都还不支持。所以,在本地开发中,可以通过mysql的配置文件,修改为老的加密方式:
如果有配置文件my.ini 就直接配置,没有在根目录直接创建。修改如下,这里我把默认端口3306 改成了3307

1
2
3
4
5
6
[client]
port=3307
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3307
default_authentication_plugin=mysql_native_password

然后重启mysql,再次使用mysql front链接,ok!

-- EOF --