Article View: cn.bbs.comp.database
Article #1664MySQL ��װ��ʹ��
From: aliang
Date: Tue, 28 Feb 2006 05:18
Date: Tue, 28 Feb 2006 05:18
245 lines
13625 bytes
13625 bytes
����:���� [���³���: www.fanqiang.com]
1999/12/24 By Coopermaa
--------------------------------------------------------------------------------
һ��ʲ���� MySQL
MySQL ������Ϊ \"My Ess Que Ell\"���� Tcx ��˾��http://www.tcx.se��������һ������ʹ�á���ִ������ SQL ���Ͽ� Server��MySQL ��Ҫ��Ŀ���ڿ��١��ȶ�������ʹ�á�
MySQL ���ڴ� http://www.mysql.net/ ȡ�á�
����MySQL �İ�װ
������ʹ�õ� MySQL �汾Ϊ mysql-3.22.27.tar.gz��ԭʼ�뵵������ҵ����Ϊ RedHat6.0 ��CLE0.8 ��
MySQL Ԥ������»ᰲװ�� /usr/local Ŀ¼�£�����Ϊ�������Ƴ�㣬���齫 mysql ������װ�� /usr/local/mysql Ŀ¼������Ϊ��װ MySQL �IJ��裺
ȡ�� mysql-3.22.27.tar.gz �ᣬ � /usr/local Ŀ¼�½��
# cd /usr/local
# tar zxvf mysql-3.22.27.tar.gz
# cd mysql-3.22.27
�趨 configure ��װѡ�ѡ��װĿ¼ ��prefix���Լ�֧Ԯ���� Big5 �루with-charset=big5����
# ./configure --prefix=/usr/local/mysql \\
#--with-charset=big5
��ʼ���벢��װ��
# make
# make install
# scripts/mysql_install_db
����һ���������������� MySQL grant tables���Ὠ��һ�� mysql ���Ͽ��һЩ tables����������ʹ�� MySQL ����Ȩ��Ѷ��Ҳ����ʹ��������Щʹ�����Ͽ��Ȩ�ޣ���
��������ֹͣ MySQL
Ҫ���� MySQL �ķ��������Ա��Ľ� MySQL ��װ�� /usr/local/mysql Ϊ��
# /usr/local/mysql/share/mysql.server start
ע���ڵ�һ��ִ��ǰ���뽫 mysql.server ��ɿ�ִ�У�chmod 744 mysql.server��������ɽ�����ָ����� /etc/rc.d/rc.local ���У��� MySQL �ڿ���ʱ�Զ�������
Ҫֹͣ MySQL �ķ�����
# /usr/local/mysql/bin/mysqladmin shutdown
�����Ϊ MySQL Administrator root �ʺţ�����ҵϵͳ�� root���������룬Ҫֹͣ MySQL �������������������MySQL ��ѯ���� root ��������Ż�ִ�� shutdown �Ĺ�����
# /usr/local/mysql/bin/mysqladmin -u root -p shutdown
�ġ�������ʹ�� MySQL ���
���㿪ʼǰ
MySQL �ṩ������ ��Client Tools������ MySQL ���Ͽ� Server ���ߣ���������Ҫ��Ϊ mysql ��̸ʽ���߹����� mysqladmin ���ó�ʽ����ʱ��ʹ������ mysql �������Ͽ� Server ��̸�����¾��� mysql ���߹������������ά����ʹ�� MySQL�����Ա��İ�װΪ��mysql ����λ� /usr/local/mysql/bin/mysql����
mysql ��ʹ������£�
mysql [-u username] [-h host] [-p[password]] [dbname]
MySQL ���Ͽ����Լ�һ��ʹ�����ʺ���Ȩ�ܿط��������������ָ���� username �� password �� MySQL ��ʹ���������룬������ҵϵͳ��ʹ���������루��Ȼ�κ�ʹ���߶���ִ�� mysql ��Ȼ���� MySQL ���κ��ʺŽ���ʹ�ã� ��
�����һ�ΰ�װ�� MySQL ʱ��MySQL �Ĺ����ʺ�Ϊ root��û���趨���� ������ҵϵͳ�� root���������ڿ�ʼǰ�����������в���Ϊ root ������룺
ʹ�� mysql �� MySQL ���Ͽ� Server ���ߣ�
# /usr/local/mysql/bin/mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection id is 201 to server version: 3.22.27
Type \'help\' for help.
mysql>
������ mysql -u root mysql ָ�ָ���� root �ʺŲ����� mysql ϵͳ���Ͽ⣬������ MySQL �ᣬ�ῴ��һЩ��ʾѶϢ�� mysql ���ߵ���ʾ��ţ�����ݵĹ������ڴ���ʾ�������ɡ�
��� MySQLϵͳ������ root ���룺
mysql> update user set password=password(\'������\') where user=\'root\';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
ע��ÿ��ָ����Ҫ����һ���ֺ� \";\" �Ż��� mysql ��ʼִ�С���ڶ���ָ����������������� mysql ϵͳ���Ͽ���£������뿪 mysql ���߳�ʽ��
�ڸ��� root �����ᣬ����Ҫ�� MySQL ���ߵķ���Ϊ��
mysql -u root -p������
������������ mysql ѯ�� root �����룺
mysql -u root -p
���Ͽ�ά��
�������������Լ�ͨѶ¼���Ͽ���Ϊ���ӣ������������ mysql ���߳�ʽ�������Ͽ��ά������������Ȩ�����ϱ�ά���ȣ���
���ȣ��� MySQL root �ʺ������Ὠ��һ addbook ���Ͽ⣺
# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection id is 207 to server version: 3.22.27
Type \'help\' for help.
mysql> create databae addbook;
Query OK, 1 row affected (0.00 sec)
ָ��ʹ�� addbook ���Ͽ⣬������һ�� friends ���ϱ?
mysql> use addbook;
Database changed
mysql> create table friends (
����-> name Char(15),
����-> telphone VarChar(20),
����-> icq Char(10),
����-> address VarChar(30)
����-> );
Query OK, 0 rows affected (0.00 sec)
�����������ϣ�����ѯ������
mysql> insert into friends values(
����-> \"maa\", \"29016710\", \"46243046\", \"̨������ׯ��\"
����-> );
Query OK, 1 row affected (0.00 sec)
mysql> insert into friends (name, icq, telphone, address ) Values (
����-> \"cxlin\", \"39425893\", \"7654321\", \"̨����\"
����-> );
Query OK, 1 row affected (0.01 sec)
mysql> select * from friends;
+-------+----------+----------+--------------+
| name | telphone | icq | address |
+-------+----------+----------+--------------+
| maa | 29016710 | 46243046 | ̨������ׯ�� |
| cxlin | 7654321 | 39425893 | ̨���� |
+-------+----------+----------+--------------+
2 rows in set (0.00 sec)
�ڶ��� insert ָ��ָ����������λ�IJ���˳���÷��ϵ�һ��Ϊ���ԣ����һ��ָ����������ϱ?���ṹʱ��˳��������ϡ�
���¡�ɾ�����ϱ��¼��
mysql> update friends set address = \"����\" where name = \"cxlin\";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from friends where name = \"cxlin\";
+-------+----------+----------+---------+
| name | telphone | icq | address |
+-------+----------+----------+---------+
| cxlin | 7654321 | 39425893 | ���� |
+-------+----------+----------+---------+
1 row in set (0.00 sec)
mysql> delete from friends where name = \"maa\";
Query OK, 1 row affected (0.01 sec)
mysql> select * from friends;
+-------+----------+----------+---------+
| name | telphone | icq | address |
+-------+----------+----------+---------+
| cxlin | 7654321 | 39425893 | ���� |
+-------+----------+----------+---------+
1 row in set (0.00 sec)
���ᣬ�������Ͽ������ϱ��ᣬ�� addbook ���Ͽ����������ϱ��ʹ��Ȩ�ޣ�select��insert��update��delete����Ȩ�� maa@localhost���ٴ����ѣ��˴��� maa Ϊ MySQL ��ʹ�����ʺţ������ҵϵͳ�� maa �ʺţ���
mysql> grant select, insert, update, delete
-> on addbook.*
-> to maa@localhost identified by \'1234567\';
Query OK, 0 rows affected (0.00 sec)
֮�ᣬ���� maa ����ݽ��� MySQL ��ȡ addbook ���Ͽ⣺
# /usr/local/mysql/bin/mysql -u maa -p addbook
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection id is 211 to server version: 3.22.27
Type \'help\' for help.
mysql> status
--------------
/mysql Ver 9.36 Distrib 3.22.27, for pc-linux-gnu (i686)
Connection id: 26
Current database: addbook
Current user: maa@localhost
Server version 3.22.27
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 2 hours 29 min 33 sec
Threads: 11 Questions: 107 Slow queries: 0 Opens: 11 Flush tables: 1
Open 7
--------------
�ջ����Ͽ�ʹ��Ȩ�ķ������£��� MySQL root ���룩��
mysql> revoke delete on addbook.* from maa@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> revoke all privileges on addbook.* from maa@localhost;
Query OK, 0 rows affected (0.00 sec)
�ڶ���ָ�������ջ�ȫ����Ȩ�ޡ�
��
�塢mysqladmin ���ó�ʽ��ʹ��
mysqladmin ���ó�ʽ������ά�� MySQL �Ƚ�һ���ԵĹ�����������ɾ�����Ͽ⡢�趨ʹ�������뼰ֹͣ MySQL �ȵȣ�����ϸ��˵������ʹ�� mysqladmin --help ���鿴�����Ա��ĵİ�װΪ�� mysqladmin λ� /usr/local/mysql/bin/mysqladmin����
�������Ͽ� dbtest
# /usr/local/mysql/bin/mysqladmin -u root -p create dbtest
Enter password:
Database \"dbtest\" created.
ɾ�����Ͽ�
# /usr/local/mysql/bin/mysqladmin -u root -p drop dbtest
Enter password:
Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.
Do you really want to drop the \'dbtest\' database [y/N]
y
Database \"dbtest\" dropped
�趨ʹ�������루�� maa �������Ϊ 7654321��mysqladmin ����ѯ�� maa ��ԭ���룩
# /usr/local/mysql/bin/mysqladmin -u maa -p password 7654321
Enter password:
#
ֹͣ MySQL ����
# ./mysqladmin -u root -p shutdown
Enter password:
ע�⣬shutdown MySQL �ᣬ��������ҵϵͳ�� root �ʺ�ִ������ָ��������� MySQL��
/usr/local/mysql/share/mysql/mysql.server start
����
MySQL ���Ͽ��ȷ��ֵ���ƹ��һ����Ʒ������ȶ����Ѿ��ȵô�ҵ���ͬ��ֻҪ����ѧϰ�� SQL Language���ṹ����ѯ���ԣ�������Ҫ���� MySQL ��ʹ��ֻ��һ����Сʱ��ʱ�䡣������ PHP ��Personal HomePage Program���� Apache Web Server����ɺ����ɽ���һ�������Ͽ��ϵĶ�̬ Web Site���������� phpMyAdmin ��� Web ���� MySQL ���?�ߣ����� MySQL �����Ͽ�� MySQL �Ĺ��?���ӷ��㡣
�ο���������Դ��
http://www.tcx.se/
MySQL 3.23 Reference Manual
The Apache Software Foundation
PHP3 PHP Hypertext Preprocessor
phpMyAdmin
--
[m[37m�� ��Դ:�� �������� http://qsuns.com��[FROM: 159.226.5.*][m
Technical Details
Message-ID:
<4Mk6cT$eGM@www.qsuns.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!news.glorb.com!nntp-server.pubsub.com!bbsnews.sdu.edu.cn!news.happynet.org!news.xjtu.edu.cn!QSUNSShow Full Headers
Complete Article Headers
X-Google-Thread: 101948,c1ab109755a18142,start X-Google-Attributes: gid101948,public X-Google-Language: Chinese,GB Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!news.glorb.com!nntp-server.pubsub.com!bbsnews.sdu.edu.cn!news.happynet.org!news.xjtu.edu.cn!QSUNS From: aliang@qsuns.com-SPAM.no (aliang) Newsgroups: cn.bbs.comp.database Subject: MySQL ��װ��ʹ�� Date: 28 Feb 2006 05:18:54 GMT Organization: �������� Lines: 245 Message-ID: <4Mk6cT$eGM@www.qsuns.com> NNTP-Posting-Host: 218.106.165.216 Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit X-Trace: irc.xjtu.edu.cn 1141103031 21681 218.106.165.216 (28 Feb 2006 05:03:51 GMT) X-Complaints-To: usenet@irc.xjtu.edu.cn NNTP-Posting-Date: Tue, 28 Feb 2006 05:03:51 +0000 (UTC) X-Filename: database/M.1141103933.N0