当前位置:Gxlcms > mysql > win7下安装绿色版mysql相关有关问题

win7下安装绿色版mysql相关有关问题

时间:2021-07-01 10:21:17 帮助过:55人阅读

win7下安装绿色版mysql相关问题 环境: 操作系统: Win7-32位 mysql版本:mysql-5.0.45-win32 安装步骤: ?1、在d:\mysql5下新建my.ini文件 [mysqld]# 设置mysql的安装目录basedir=D:\mysql5# 设置mysql数据库的数据的存放目录,必须是data,或者是\\xxx\data

win7下安装绿色版mysql相关问题

环境:

操作系统: Win7-32位

mysql版本:mysql-5.0.45-win32

安装步骤:

?1、在d:\mysql5下新建my.ini文件

  1. [mysqld]
  2. # 设置mysql的安装目录
  3. basedir=D:\mysql5
  4. # 设置mysql数据库的数据的存放目录,必须是data,或者是\\xxx\data
  5. datadir=D:\mysql5\data
  6. # 设置mysql服务器的字符集
  7. character-set-server=utf8
  8. [client]
  9. # 设置mysql客户端的字符集
  10. default-character-set=gbk

2、打开cmd,进入mysql解压目录D:/mysql5/bin下,输入命令

  1. mysqld --console

?显示如下信息:

  1. D:\mysql5\bin>mysqld --console
  2. 131001 18:13:23 InnoDB: Started; log sequence number 0 43655
  3. 131001 18:13:24 [Note] mysqld: ready for connections.
  4. Version: '5.0.45-community-nt' socket: '' port: 3306 MySQL Community Edition
  5. (GPL)

?表示mysql启动成功。

3、新开cmd窗口,输入命令:

  1. D:\mysql5\bin>mysql -u root
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 1
  4. Server version: 5.0.45-community-nt MySQL Community Edition (GPL)
  5. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  6. mysql> status
  7. --------------
  8. mysql Ver 14.12 Distrib 5.0.45, for Win32 (ia32)
  9. Connection id: 1
  10. Current database:
  11. Current user: root@localhost
  12. SSL: Not in use
  13. Using delimiter: ;
  14. Server version: 5.0.45-community-nt MySQL Community Edition (GPL)
  15. Protocol version: 10
  16. Connection: localhost via TCP/IP
  17. Server characterset: utf8
  18. Db characterset: utf8
  19. Client characterset: gbk
  20. Conn. characterset: gbk
  21. TCP port: 3306
  22. Uptime: 7 sec
  23. Threads: 1 Questions: 4 Slow queries: 0 Opens: 12 Flush tables: 1 Open tabl
  24. es: 6 Queries per second avg: 0.571
  25. --------------
  26. mysql>

?完成。

?

?其他:

一、将mysql注册为系统服务:

?

  1. D:\mysql5\bin>mysqld --install mysql5 --defaults-file=D:\mysql5\my.ini
  2. Service successfully installed.
  3. D:\mysql5\bin>net start mysql5
  4. mysql5 服务正在启动 .
  5. mysql5 服务已经启动成功。
?关闭:net stop mysql5

?

删除服务:mysqld --remove mysql5

二、修改root用户密码

?

  1. D:\mysql5\bin>mysql -u root
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 2
  4. Server version: 5.5.34 MySQL Community Server (GPL)
  5. Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. mysql> update mysql.user set password=PASSWORD('root') where user='root' or user
  11. ='';
  12. Query OK, 4 rows affected (0.03 sec)
  13. Rows matched: 4 Changed: 4 Warnings: 0
  14. mysql> grant all on *.* to root@'%' identified by 'root';
  15. Query OK, 0 rows affected (0.02 sec)
  16. mysql> commit;
  17. Query OK, 0 rows affected (0.00 sec)
  18. mysql> flush privileges;
  19. Query OK, 0 rows affected (0.00 sec)
  20. mysql>
?附带mysql相关命令
  1. 附带mysql的一些简单操作:
  2. 第一招、mysql服务的启动和停止(针对安装版,或者压缩版已注册服务)
  3. net stop mysql
  4. net start mysql
  5. 第二招、登陆mysql
  6. 语法如下: mysql -u用户名 -p用户密码
  7. 键入命令mysql -uroot -p, 回车后提示你输入密码,输入12345,然后回车即可进入到mysql中了,mysql的提示符是:
  8. mysql>
  9. 注意,如果是连接到另外的机器上,则需要加入一个参数-h机器IP
  10. 第三招、增加新用户
  11. 格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码"
  12. 如,增加一个用户user1密码为password1,让其可以在本机上登录, 并对所有数据库有查询、插入、修改、删除的权限。首先用以root用户连入mysql,然后键入以下命令:
  13. grant select,insert,update,delete on *.* to user1@localhost Identified by "password1";
  14. 如果希望该用户能够在任何机器上登陆mysql,则将localhost改为"%"。
  15. 如果你不想user1有密码,可以再打一个命令将密码去掉。
  16. grant select,insert,update,delete on mydb.* to user1@localhost identified by "";
  17. 第四招: 操作数据库
  18. 登录到mysql中,然后在mysql的提示符下运行下列命令,每个命令以分号结束。
  19. 1、 显示数据库列表。
  20. show databases;
  21. 缺省有两个数据库:mysql和test。 mysql库存放着mysql的系统和用户权限信息,我们改密码和新增用户,实际上就是对这个库进行操作。
  22. 2、 显示库中的数据表:
  23. use mysql;
  24. show tables;
  25. 3、 显示数据表的结构:
  26. describe 表名;
  27. 4、 建库与删库:
  28. create database 库名;
  29. drop database 库名;
  30. 5、 建表:
  31. use 库名;
  32. create table 表名(字段列表);
  33. drop table 表名;
  34. 6、 清空表中记录:
  35. delete from 表名;
  36. 7、 显示表中的记录:
  37. select * from 表名;
  38. 第五招、导出和导入数据
  39. 1. 导出数据:
  40. mysqldump --opt test > mysql.test
  41. 即将数据库test数据库导出到mysql.test文件,后者是一个文本文件
  42. 如:mysqldump -u root -p123456 --databases dbname > mysql.dbname
  43. 就是把数据库dbname导出到文件mysql.dbname中。
  44. 2. 导入数据:
  45. mysqlimport -u root -p123456 < mysql.dbname。
  46. 不用解释了吧。
  47. 3. 将文本数据导入数据库:
  48. 文本数据的字段数据之间用tab键隔开。
  49. use test;
  50. load data local infile "文件名" into table 表名;
  51. 1:使用SHOW语句找出在服务器上当前存在什么数据库:
  52. mysql> SHOW DATABASES;
  53. 2:2、创建一个数据库MYSQLDATA
  54. mysql> CREATE DATABASE MYSQLDATA;
  55. 3:选择你所创建的数据库
  56. mysql> USE MYSQLDATA; (按回车键出现Database changed 时说明操作成功!)
  57. 4:查看现在的数据库中存在什么表
  58. mysql> SHOW TABLES;
  59. 5:创建一个数据库表
  60. mysql> CREATE TABLE MYTABLE (name VARCHAR(20), sex CHAR(1));
  61. 6:显示表的结构:
  62. mysql> DESCRIBE MYTABLE;
  63. 7:往表中加入记录
  64. mysql> insert into MYTABLE values ("hyq","M");
  65. 8:用文本方式将数据装入数据库表中(例如D:/mysql.txt)
  66. mysql> LOAD DATA LOCAL INFILE "D:/mysql.txt" INTO TABLE MYTABLE;
  67. 9:导入.sql文件命令(例如D:/mysql.sql)
  68. mysql>use database;
  69. mysql>source d:/mysql.sql;
  70. 10:删除表
  71. mysql>drop TABLE MYTABLE;
  72. 11:清空表
  73. mysql>delete from MYTABLE;
  74. 12:更新表中数据
  75. mysql>update MYTABLE set sex="f" where name='hyq';
  76. posted on 2006-01-10 16:21 happytian 阅读(6) 评论(0) 编辑 收藏 收藏至365Key
  77. 13:备份数据库
  78. mysqldump -u root 库名>xxx.data
  79. 14:例2:连接到远程主机上的MYSQL
  80. 假设远程主机的IP为:110.110.110.110,用户名为root,密码为abcd123。则键入以下命令:
  81. mysql -h110.110.110.110 -uroot -pabcd123 // 远程登录
  82. (注:u与root可以不用加空格,其它也一样)
  83. 3、退出MYSQL命令: exit (回车)
?参考:http://blog.csdn.net/huangxy10/article/details/8264187

?

?????????? http://www.blogjava.net/wldandan/archive/2007/09/24/147796.html

人气教程排行