<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.saruman.biz/saruwiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JamilaCloud</id>
	<title>SaruWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.saruman.biz/saruwiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JamilaCloud"/>
	<link rel="alternate" type="text/html" href="https://www.saruman.biz/saruwiki/index.php/Special:Contributions/JamilaCloud"/>
	<updated>2026-05-02T09:28:48Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://www.saruman.biz/saruwiki/index.php?title=Database_101&amp;diff=2567</id>
		<title>Database 101</title>
		<link rel="alternate" type="text/html" href="https://www.saruman.biz/saruwiki/index.php?title=Database_101&amp;diff=2567"/>
		<updated>2010-05-18T14:41:09Z</updated>

		<summary type="html">&lt;p&gt;JamilaCloud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== MySQL installation ==&lt;br /&gt;
As with any package to be installed: use aptitude, update your APT, then make sure all your (other) software is up-to-date. Then find package &#039;&#039;mysql-server&#039;&#039; - under Debian 5.0 &amp;quot;Lenny&amp;quot; it&#039;ll be version 5.0.51a-something. Installing it will also automatically install some dependent packages, like mysql-common, mysql-client etcetera. So after downloading some 40MiB of files, MySQL is installed. The installation script under Debian Lenny asks you for a password for the MySQL root user. Think up a strong password for the MySQL root user; something like &#039;&#039;waYacUbaT2uW&#039;&#039;. DON&#039;T use this example password, [http://www.pctools.com/guides/password/ generate your own one!]. DO NOT use the password of the Linux &#039;&#039;root&#039;&#039; user. [http://www.writers.ph writing jobs]&lt;br /&gt;
&lt;br /&gt;
Should you consult [http://dev.mysql.com/doc/refman/5.0/en/unix-post-installation.html the official MySQL documentation], you might see mention of the &#039;&#039;mysql_install_db&#039;&#039; script - do not worry about that, since Debian has run it for you when it was setting up the database.&lt;br /&gt;
&lt;br /&gt;
The standard user accounts that have been created by the installation script are:&lt;br /&gt;
* &#039;root&#039;@&#039;localhost&#039;&lt;br /&gt;
* &#039;root&#039;@&#039;&amp;lt;hostname&amp;gt;&#039;&lt;br /&gt;
* &#039;root&#039;@&#039;127.0.0.1&#039;&lt;br /&gt;
All three root accounts are secured with the same password, the one you specified when installing the package &#039;&#039;mysql-server&#039;&#039;.&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;NOTE for Debian 4.0 &amp;quot;Etch&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
When you install MySQL under Etch, there are two root accounts with empty passwords, and two anonymous accounts. NOT safe! You&#039;ll want to rectify this in order to secure your MySQL server. Please take the following steps. Start the MySQL client from the command line:&lt;br /&gt;
 mysql -u root&lt;br /&gt;
Then, from the mysql client prompt, set the password for the MySQL root users. They can be treated as two different accounts, but we don&#039;t recommend that. We thus give both accounts the same password:&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR &#039;root&#039;@&#039;localhost&#039; = PASSWORD(&#039;waYacUbaT2uW&#039;);&lt;br /&gt;
 mysql&amp;gt; SET PASSWORD FOR &#039;root&#039;@&#039;&amp;lt;hostname&amp;gt;&#039; = PASSWORD(&#039;waYacUbaT2uW&#039;);&lt;br /&gt;
Furthermore, there are two anonymous accounts created. These also have no password, and get full permission on the &#039;&#039;test&#039;&#039; database, as well as on any database who&#039;s name begins with &#039;&#039;test_&#039;&#039;. These accounts can be fitted with a password (like we did for root - just use two quotes with nothing in between them, instead of two quotes with &#039;&#039;root&#039;&#039; in between), or they can be removed - which we recommend. The (single) command for this is:&lt;br /&gt;
&amp;lt;pre&amp;gt;mysql&amp;gt; DROP USER &#039;&#039;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;End of NOTE&#039;&#039;&#039;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
To verify the installation you might want to take some of the following steps:&lt;br /&gt;
* run &#039;&#039;mysqlshow -u root -p&#039;&#039;, and see if that command outputs at least two databases (&#039;&#039;information_schema&#039;&#039; and &#039;&#039;mysql&#039;&#039;);&lt;br /&gt;
* check out the settings of your MySQL server by running &#039;&#039;mysqladmin -u root -p variables&#039;&#039; (piping the output to &#039;&#039;less&#039;&#039; or a file, if necessary);&lt;br /&gt;
* have a peek in &#039;&#039;/var/lib/mysql&#039;&#039;; the database data files should be there;&lt;br /&gt;
* check &#039;&#039;/var/log&#039;&#039; for two logfiles &#039;&#039;mysql.err&#039;&#039; and &#039;&#039;mysql.log&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Moving the MySQL databases==&lt;br /&gt;
By default the location of your Debian MySQL databases is &#039;&#039;/var/lib/mysql/&amp;lt;database&amp;gt;&#039;&#039;. However, sometimes you wish your databases to be in a different location. E.g. &#039;&#039;/data/mysql&#039;&#039;, where &#039;&#039;/data&#039;&#039; is a mounted dedicated RAID array. Or perhaps even &#039;&#039;/data/mysql&#039;&#039; is its own array.&lt;br /&gt;
&lt;br /&gt;
Whatever the reason, to move &#039;&#039;all&#039;&#039; MySQL databases from &#039;&#039;/var/lib/mysql&#039;&#039; to another location, you can follow these steps:&lt;br /&gt;
* Create the new directory, e.g. &#039;&#039;/data/mysql&#039;&#039;&lt;br /&gt;
* Make this directory owned by user/group &#039;&#039;mysql&#039;&#039;&lt;br /&gt;
 cd /data&lt;br /&gt;
 mkdir mysql&lt;br /&gt;
 chown mysql:mysql mysql&lt;br /&gt;
* Shut down the database server with one of the following commands:&lt;br /&gt;
 mysqladmin -u root -p shutdown&lt;br /&gt;
 invoke-rc.d mysql stop&lt;br /&gt;
* Make a backup copy of &#039;&#039;/etc/mysql/my.cnf&#039;&#039;, then edit this file. Find the section &#039;&#039;[mysqld]&#039;&#039; and change the line &#039;&#039;datadir         = /var/lib/mysql&#039;&#039; to&lt;br /&gt;
 datadir         = /data/mysql&lt;br /&gt;
* As root, move (or better yet: copy) &#039;&#039;all&#039;&#039; of the content of &#039;&#039;/var/lib/mysql&#039;&#039; over to &#039;&#039;/data/mysql&#039;&#039;. Make sure you don&#039;t accidentally change the ownership or permissions of the files and folders in the &#039;&#039;/var/lib/mysql&#039;&#039; folder. We expect each and every file and folder to be owned by &#039;&#039;mysql:mysql&#039;&#039;. Copy command would be (as root):&lt;br /&gt;
 cp -p -r /var/lib/mysql/* /data/mysql&lt;br /&gt;
* Check and doublecheck your &#039;&#039;my.cnf&#039;&#039; settings and your database file owners, attributes and size. After the next step, there &#039;&#039;may&#039;&#039; be no way back!&lt;br /&gt;
* Start up your database server:&lt;br /&gt;
 invoke-rc.d mysql start&lt;br /&gt;
* Check the working of your MySQL server:&lt;br /&gt;
** issue the following command to get status information (to see if MySQL is running after your start command):&lt;br /&gt;
 invoke-rc.d mysql status&lt;br /&gt;
** look under &#039;&#039;/var/log&#039;&#039; for the default MySQL log files &#039;&#039;mysql.log&#039;&#039; and &#039;&#039;mysql.err&#039;&#039;&lt;br /&gt;
** check your SysLog (standard: &#039;&#039;/var/log/syslog&#039;&#039;) for MySQL error messages, since the default Debian configuration is to log MySQL errors there, rather than in the previously mentioned MySQL logfiles.&lt;br /&gt;
&lt;br /&gt;
== MySQL commands ==&lt;br /&gt;
The following are examples of the most common MySQL commands&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
SHOW DATABASES;&lt;br /&gt;
USE &amp;lt;database&amp;gt;;&lt;br /&gt;
SHOW TABLES;&lt;br /&gt;
DESCRIBE &amp;lt;table&amp;gt;;&lt;br /&gt;
SELECT &amp;lt;col1&amp;gt;,&amp;lt;col2&amp;gt;...&amp;lt;col_i&amp;gt; FROM &amp;lt;table&amp;gt; WHERE &amp;lt;column&amp;gt; = &#039;&amp;lt;value&amp;gt;&#039;;&lt;br /&gt;
INSERT INTO &amp;lt;table&amp;gt; (&amp;lt;col1&amp;gt;,&amp;lt;col2&amp;gt;...&amp;lt;col_i&amp;gt;) VALUES (&amp;lt;val1&amp;gt;,&amp;lt;val2&amp;gt;...&amp;lt;val_i&amp;gt;);&lt;br /&gt;
UPDATE &amp;lt;table&amp;gt; set &amp;lt;col1&amp;gt; = &#039;&amp;lt;value1&amp;gt;&#039; WHERE &amp;lt;column&amp;gt; = &#039;&amp;lt;value&amp;gt;&#039;;&lt;br /&gt;
DELETE FROM &amp;lt;table&amp;gt; WHERE &amp;lt;column&amp;gt; = &#039;&amp;lt;value&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Ofcourse there are more useful commands, see the MySQL website.&lt;/div&gt;</summary>
		<author><name>JamilaCloud</name></author>
	</entry>
</feed>