日期:2014-05-16  浏览次数:20841 次

MySQL问题集锦

?

一、下载(免安装Archive版)

???下载地址:http://dev.mysql.com/downloads/mysql/

????

?

二、安装

1.解压到目录:D:\mysql-5.1.59-winx64

2.注册mysql服务,命令行跳转到D:\mysql-5.1.59-winx64\bin,执行以下命令:

D:\mysql-5.1.59-winx64\bin>mysqld install mysql
Service successfully installed.

3.移除mysql服务,命令行跳转到D:\mysql-5.1.59-winx64\bin,执行以下命令:

D:\mysql-5.1.59-winx64\bin>mysqld remove mysql
Service successfully removed.

?

4.启动停止mysql服务

??? 启动

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

?

??? 停止

C:\>net stop mysql
MySQL 服务正在停止...
MySQL 服务已成功停止。

?

5.设置服务自动启动

D:\>sc config mysql start= auto
[SC] ChangeServiceConfig 成功

注:start与=号之间不能有空格,=号与auto之间必须有一个空格?

?

三.、配置

在D:\mysql-5.1.59-winx64目录下,有5个配置文件模板, 分别为:

??????? my-small.ini、

??????? my-medium.ini、

??????? my-large.ini、

??????? my-huge.ini、

??????? my-innodb-heavy-4G.ini

1.我们选择my-innodb-heavy-4G.ini,作为配置模板

2.将其改名为:my.ini

3.修改默认引擎:找到default-storage-engine =?MYISAM 这段,将其改为default-storage-engine = INNODB

4.修改默认引擎为INNODB后,可能导致服务器启动失败:删除在MySQL安装目录下的Data目录中的ib_logfile0,ib_logfile1,ibdata1三个文件,重新启动即可

5.修改默认编码:

????????? 打开my.ini文件

??????????[client] 段添加:? default-character-set=utf8

??????????[mysqld]段添加:character-set-server=utf8

[client]
port		= 3306
socket		= MySQL
default-character-set=utf8

[mysqld]
port		= 3306
socket		= MySQL
character-set-server=utf8

?

?????????

?

?

四、常用命令

1.命令行登陆:mysql -uroot -proot

D:\mysql-5.1.59-winx64\bin>mysql -uroot -proot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.59-community-log MySQL Community Server (GPL)

Copyright (c) 2000, 2011, 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>

?

2.查看数据库 show databases;

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

?

2.查看数据库表 use dbname; show tables;

mysql> use mysql;
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
23 rows in set (0.03 sec)

?

3.查看数据配置变量信息 show variables;

?

mysql> show variables like '%innodb%';
+-----------------------------------------