1 |
fox2mike 05/08/24 11:51:02 |
2 |
|
3 |
Added: xml/htdocs/doc/en/draft mysql-howto.xml |
4 |
Log: |
5 |
Putting it here for a check-up + some URLification. |
6 |
|
7 |
Revision Changes Path |
8 |
1.1 xml/htdocs/doc/en/draft/mysql-howto.xml |
9 |
|
10 |
file : http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/draft/mysql-howto.xml?rev=1.1&content-type=text/x-cvsweb-markup&cvsroot=gentoo |
11 |
plain: http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/draft/mysql-howto.xml?rev=1.1&content-type=text/plain&cvsroot=gentoo |
12 |
|
13 |
Index: mysql-howto.xml |
14 |
=================================================================== |
15 |
<?xml version="1.0" encoding="UTF-8"?> |
16 |
<!DOCTYPE guide SYSTEM "http://www.gentoo.org/dtd/guide.dtd"> |
17 |
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/draft/mysql-howto.xml,v 1.1 2005/08/24 11:51:02 fox2mike Exp $ --> |
18 |
|
19 |
<guide link="/doc/en/mysql-howto.xml"> |
20 |
<title>MySQL Startup Guide</title> |
21 |
|
22 |
<author title="Author"> |
23 |
<mail link="chriswhite@g.o">Chris White</mail> |
24 |
</author> |
25 |
<author title="Editor"> |
26 |
<mail link="fox2mike@g.o">Shyam Mani</mail> |
27 |
</author> |
28 |
|
29 |
<abstract> |
30 |
This document helps a user setup and use MySQL. |
31 |
</abstract> |
32 |
|
33 |
<!-- The content of this document is licensed under the CC-BY-SA license --> |
34 |
<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> |
35 |
<license/> |
36 |
|
37 |
<version>1.0</version> |
38 |
<date>2005-08-24</date> |
39 |
|
40 |
<chapter> |
41 |
<title>Getting Started With MySQL</title> |
42 |
<section> |
43 |
<title>Background</title> |
44 |
<body> |
45 |
|
46 |
<p> |
47 |
MySQL is a popular database server that is used in various applications. SQL |
48 |
stands for (S)tandard (Q)uery (L)anguage, which is what MySQL uses to |
49 |
communicate with other programs. On top of that, MySQL has its own expanded |
50 |
SQL functions to provide additional functionality to users. In this document, |
51 |
we'll look at how to do the initial MySQL installation, setup databases and |
52 |
tables and create new users. Let's start out with the installation. |
53 |
</p> |
54 |
|
55 |
</body> |
56 |
</section> |
57 |
<section> |
58 |
<title>MySQL Installation</title> |
59 |
<body> |
60 |
|
61 |
<p> |
62 |
First make sure you have MySQL installed on your system. In case you need |
63 |
specific functionality from MySQL, please make sure you have the required USE |
64 |
flags enabled as they will help fine tune your installation. |
65 |
</p> |
66 |
|
67 |
<pre caption="Install MySQL"> |
68 |
<comment>(Viewing available USE flags)</comment> |
69 |
# <i>emerge --pretend --verbose mysql</i> |
70 |
<comment>(Install MySQL)</comment> |
71 |
# <i>emerge mysql</i> |
72 |
</pre> |
73 |
|
74 |
<p> |
75 |
Upon completion of the installation, you will see the following notice: |
76 |
</p> |
77 |
|
78 |
<pre caption="MySQL einfo message"> |
79 |
You might want to run: |
80 |
"ebuild /var/db/pkg/dev-db/mysql-[version]/mysql-[version].ebuild config" |
81 |
if this is a new install. |
82 |
</pre> |
83 |
|
84 |
<p> |
85 |
Since this is a new installation, we run the command. You need to press |
86 |
<c>ENTER</c> when prompted while configuring the MySQL database. The |
87 |
configuration sets up the main MySQL database which contains administrative |
88 |
information such as databases, tables, users, permissions and more. The |
89 |
configuration recommends that you change your root password as soon as possible. |
90 |
We will definitely do this, otherwise someone could come along by chance and |
91 |
hack our default setup MySQL server. |
92 |
</p> |
93 |
|
94 |
<pre caption="MySQL configuration"> |
95 |
# <i>ebuild /var/db/pkg/dev-db/mysql-[version]/mysql-[version].ebuild config</i> |
96 |
* MySQL DATADIR is /var/lib/mysql |
97 |
* Press ENTER to create the mysql database and set proper |
98 |
* permissions on it, or Control-C to abort now... |
99 |
|
100 |
Preparing db table |
101 |
Preparing host table |
102 |
Preparing user table |
103 |
Preparing func table |
104 |
Preparing tables_priv table |
105 |
Preparing columns_priv table |
106 |
Installing all prepared tables |
107 |
|
108 |
To start mysqld at boot time you have to copy support-files/mysql.server |
109 |
to the right place for your system |
110 |
|
111 |
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! |
112 |
To do so, issue the following commands to start the server |
113 |
and change the applicable passwords: |
114 |
<comment>(Note the next 3 lines)</comment> |
115 |
/etc/init.d/mysql start |
116 |
/usr/bin/mysqladmin -u root -h pegasos password 'new-password' |
117 |
/usr/bin/mysqladmin -u root password 'new-password' |
118 |
Depending on your configuration, a -p option may be needed |
119 |
in the last command. See the manual for more details. |
120 |
|
121 |
<comment>(Some MySQL non-ebuild specific information has been removed from here |
122 |
so as to keep this document as consistent as possible)</comment> |
123 |
|
124 |
* For security reasons you should set your MySQL root |
125 |
* password as soon as possible. |
126 |
</pre> |
127 |
|
128 |
<impo> |
129 |
As of mysql-4.0.24-r2, passwords are entered during the config phase making |
130 |
root password entry more secure. |
131 |
</impo> |
132 |
|
133 |
<p> |
134 |
The config script has already printed out the commands we need to run to setup |
135 |
our password, so we shall now run them. |
136 |
</p> |
137 |
|
138 |
<pre caption="Setting up your MySQL root password"> |
139 |
# <i>/etc/init.d/mysql start</i> |
140 |
* Re-caching dependency info (mtimes differ)... |
141 |
* Starting mysqld (/etc/mysql/my.cnf) ... [ ok ] |
142 |
<comment>(Replace new-password with your desired password)</comment> |
143 |
# <i>/usr/bin/mysqladmin -u root -h localhost password 'new-password'</i> |
144 |
</pre> |
145 |
|
146 |
<p> |
147 |
You can now test that your root password was successfully configured by trying |
148 |
to login to your MySQL server: |
149 |
</p> |
150 |
|
151 |
<pre caption="Logging into the MySQL server using mysql"> |
152 |
$ <i>mysql -u root -h localhost -p</i> |
153 |
Enter password: |
154 |
Welcome to the MySQL monitor. Commands end with ; or \g. |
155 |
Your MySQL connection id is 4 to server version: 4.0.24-debug |
156 |
|
157 |
Type 'help;' or '\h' for help. Type '\c' to clear the buffer. |
158 |
|
159 |
mysql> |
160 |
</pre> |
161 |
|
162 |
<p> |
163 |
The <c>-u</c> switch sets the user that will be logging in. The <c>-h</c> |
164 |
switch sets the host. This will usually be <c>localhost</c> unless you are |
165 |
setting up a remote server. Finally, <c>-p</c> tells the mysql client that you |
166 |
will be entering a password to access your database. Notice the |
167 |
<c>mysql></c> prompt. This is where you type in all your commands. Now that |
168 |
we're in the mysql prompt as the root user, we can begin to setup our database. |
169 |
</p> |
170 |
|
171 |
</body> |
172 |
</section> |
173 |
</chapter> |
174 |
|
175 |
<chapter> |
176 |
<title>Setting Up The Database</title> |
177 |
<section> |
178 |
<title>Creating A Database</title> |
179 |
<body> |
180 |
|
181 |
<p> |
182 |
We have logged in and have a mysql prompt displayed. First let's take a look at |
183 |
the databases we currently have. To do so, we use the <c>SHOW DATABASES</c> |
184 |
command. |
185 |
</p> |
186 |
|
187 |
<pre caption="Displaying MySQL databases"> |
188 |
mysql> <i>SHOW DATABASES;</i> |
189 |
+----------+ |
190 |
| Database | |
191 |
+----------+ |
192 |
| mysql | |
193 |
| test | |
194 |
+----------+ |
195 |
2 rows in set (0.09 sec) |
196 |
</pre> |
197 |
|
198 |
<impo> |
199 |
Please remember that MySQL commands should end with a semicolon -- <c>;</c> |
200 |
</impo> |
201 |
|
202 |
<p> |
203 |
Despite the fact that a test database is already created, we are going to create |
204 |
our own. Databases are created using the <c>CREATE DATABASE</c> command. We'll |
205 |
create one named "gentoo". |
206 |
</p> |
207 |
|
208 |
<pre caption="Creating the gentoo database"> |
209 |
mysql> <i>CREATE DATABASE gentoo;</i> |
210 |
Query OK, 1 row affected (0.08 sec) |
211 |
</pre> |
212 |
|
213 |
<p> |
214 |
|
215 |
|
216 |
|
217 |
-- |
218 |
gentoo-doc-cvs@g.o mailing list |