说说在 linux 环境下,如何新建 MySQL 数据库实例

使用 secureCRT,远程登录 linux 服务器。

然后使用以下命令,登录 MySQL 服务器:

mysql -u<账号> -p<密码>

一般使用有新建数据库权限的账号。

登录成功后,会出现欢迎提示:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 23674
Server version: 5.6.19-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

然后命令行前缀变为 mysql> 盘符。

使用以下命令创建数据库实例:

create database <数据库实例名称>;

注意:mysql 内的每个命令都必须以分号结尾。

最后使用 show 命令,列出当前所有的数据库实例:

show databases;

这时就会看到我们刚刚新建的数据库实例啦,是不是很简单呀O(∩_∩)O哈哈~


注意:MySQL 默认是使用 latin 作为数据库实例的字符集的,所以我们需要修改它:

alter database 数据库名 character set utf8;

如果是之后修改的数据库实例字符集,那么会立即生效,不需要重启 MySQL 服务器哦O(∩_∩)O哈哈~

你可能感兴趣的:(数据库,MySQL)