mysql绿色版配置

 

MySQL 绿色版安装配置教程

一、下载,这里使用绿色免安装版

1.网上搜索mysql绿色免安装版下载即可。提供官网地址 http://dev.mysql.com/downloads/mysql------- ps:需要登录oracle账户,自行注册。
2.或者可下载笔者提供的较新版mysql-5.6.24(64位和32位都已分享,根据需要下载),附百度云盘地址:链接: http://pan.baidu.com/s/1dDClFUD 密码: 6mq9

二、配置MySQL的参数

1、解压缩绿色版软件到E:\mysql-5.6.24
设置系统环境变量
在Path中添加路径,如:笔者放在E盘下则配置为E:\mysql-5.6.24\bin;  ps:尽量加在首端位置

2、进行mysql数据库的基本的配置,即在my-default.ini文件中进行mysql数据库的基本的配置,笔者在这里做的基本的配置是实现了mysql的安装路径,以及端口号等的配置;

basedir =E:/mysql-5.6.24
datadir =E:/mysql-5.6.24/data
port =3306
server_id =10

将修改后的文件另存为my.ini

3、如上的操作完成以后,
1)、cmd进入命令窗口,在命令窗口下进入E:\mysql-5.6.24
2)、执行安装MySQL服务名的命令:
mysqld --install MySQL –defaults-file=“你的ini文件路径,也就是上面修改的文件路径”(如果没修改文件文件名,就用原来的my-default.ini)
如:
mysqld --install MySQL --defaults-file="E:\mysql-5.6.24\my.ini"
提示安装服务成功
Service successfully installed.
3)、启动MySQL服务命令:
net start mysql
MySQL服务正在启动 ...

4)、登陆MySQL服务器
在命令窗口下进入E:\mysql-5.6.24\bin执行如下命令:
mysql -uroot -p
Enter password:     (ps:默认初始密码为空)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.32-community MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

注意:MySQL的管理员用户名为root,密码默认为空。

5)、查看数据库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.02 sec)

可以看到MySQL服务器中有三个数据库。

6)、使用数据库
mysql> use test
Database changed

7)、查看数据库中的表
mysql> show tables;
Empty set (0.00 sec)

8)、创建表ttt
mysql> create table ttt(a int,b varchar(20));
Query OK, 0 rows affected (0.00 sec)

9)、插入三条数据
mysql> insert into ttt values(1,'aaa');
Query OK, 1 row affected (0.02 sec)

mysql> insert into ttt values(2,'bbb');
Query OK, 1 row affected (0.00 sec)

mysql> insert into ttt values(3,'ccc');
Query OK, 1 row affected (0.00 sec)

10)、查询数据
mysql> select * from ttt;
+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | bbb |
| 3 | ccc |
+------+------+
3 rows in set (0.00 sec)

11)、删除数据
mysql> delete from ttt where a=3;
Query OK, 1 row affected (0.01 sec)

删除后查询操作结果:
mysql> select * from ttt;
+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | bbb |
+------+------+
2 rows in set (0.00 sec)

12)、更新数据
mysql> update ttt set b = 'xxx' where a =2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

查看更新结果:
mysql> select * from ttt;
+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | xxx |
+------+------+
2 rows in set (0.00 sec)

13)、删除表
mysql> drop table ttt;
Query OK, 0 rows affected (0.00 sec)

查看数据库中剩余的表:
mysql> show tables;
Empty set (0.00 sec)

三、更改MySQL数据库root用户的密码

1、使用mysql数据库:
mysql> use mysql
Database changed
2、更改密码:
mysql>update user set Password=password('123456') where User='root';(新版好像不能用了)

mysql>set password for 'root'@'localhost'=password('123');

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

3、重启MySQL:更改了MySQL用户后,需要重启MySQL服务器才可以生效。
net stop mysql
MySQL 服务正在停止..
MySQL 服务已成功停止。

net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

4、重新登陆MySQL服务器
mysql -uroot -p
Enter password: 123456

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.32-community MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

四、数据库的创建与删除

1、创建数据库testdb
mysql> create database testdb;
Query OK, 1 row affected (0.02 sec)

2、使用数据库testdb
mysql> use testdb;
Database changed

3、删除数据库testdb
mysql> drop database testdb;
Query OK, 0 rows affected (0.00 sec)

4、退出登陆
mysql>exit
Bye

C:\Documents and Settings\Administrator>

五、操作数据库数据的一般步骤

1、启动MySQL服务器
2、登陆数据库服务器
3、使用某个要操作的数据库
4、操作该数据库中的表,可执行增删改查各种操作。
5、退出登陆。

---------

修改密码:mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
初始化:bin/mysqld --initialize-insecure(密码为空)

 ------------------

然后运行

mysqld --initialize --console

命令。执行过后找到A temporary password is generated for root@localhost: 这句,localhost后面就是自己的初始化密码

启动服务输入

net start mysql

输入

mysql -u root -p

进行登录数据库,这时提示需要密码,然后就是用你上面的密码登录
修改密码语句:

ALTER USER root@localhost IDENTIFIED BY ‘123456’;

修改密码为:123456
若要删除mysql,可执行命令

mysqld --remove mysql

posted @ 2016-09-27 20:01  疯陈演义  阅读(541)  评论(0编辑  收藏  举报