Mysql 配置以及常用命令

1.下载解压包

2.配置my.ini

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
character-set-server=utf8

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = E:\Program Files\mysql-5.7.22-winx64
datadir = E:\Program Files\mysql-5.7.22-winx64\data
# port = .....
# server_id = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

3.安装

mysqld -install
mysql -remove
mysql -ininstal
net start mysql 启动服务
net stop mysql

4.登录

登录
mysql -u user -p
修改密码

这里如果是面密码登录,刷新权限

flush privileges
set passwd for user@localhost=password("123456");

5.mysql 的使用

create databses test_db;
show databses LIKE 'test_db';
创建表:
create table test_db
(
id int(11),
name varchar(25)
);
显示表
desc test_db;
show create table test_db\G;

6.修改表

首先输入开始 然后附加参数
alter table test_db
ADD COLUMN col1 INT FIRST;
ADD COLUMN col2 INT AFTER name;
MODIFY name VARCHAR(30);
DROP col2;
CHANGE col1 col3 CHAR(30);
RENAME TO tb_emp2;

drop table test_db ;

注意配置

mysqld -install
mysqld -inittial *******************************
net start mysql
net stop mysql
mysql -u root -p

你可能感兴趣的:(Mysql 配置以及常用命令)