1.登录mysql控制台
mysql -u root -p
2.创建database
mysql> CREATE DATABASE Name
3. 查询一个数据库的所有表
SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '数据库名'
4.删除表
mysql> DROP table 表名;
5.显示所有db
mysql> show databases;
6.导入带数据的sql
mysql>source test.sql;
7.导出数据至excel
select * into outfile '/var/lib/mysql-files/1.xls' from table_2;
可能会出现的错误: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
需要检查自己的secure-file-priv设置的是什么,然后将outfile改为相应路径。
mysql> show variables like '%secure%';
+--------------------------+-----------------------+
| Variable_name | Value |
+--------------------------+-----------------------+
| require_secure_transport | OFF |
| secure_auth | ON |
| secure_file_priv | /var/lib/mysql-files/ |
+--------------------------+-----------------------+
3 rows in set (0.00 sec)