<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technical Diary &#187; Databases</title>
	<atom:link href="http://andriigrytsenko.net/category/databases/feed/" rel="self" type="application/rss+xml" />
	<link>http://andriigrytsenko.net</link>
	<description>With Andrii Grytsenko</description>
	<lastBuildDate>Sun, 01 Apr 2012 11:10:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Mysql master/slave replication</title>
		<link>http://andriigrytsenko.net/2011/02/mysql-replication/</link>
		<comments>http://andriigrytsenko.net/2011/02/mysql-replication/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 23:33:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=873</guid>
		<description><![CDATA[The replication mechanism is very powerful and useful feature. Here I will try to briefly describe how to set it up. You can read more about replication there. To get to know more about replication format and which is more suitable for you read this. There are different relationship type of replication which can be [...]]]></description>
			<content:encoded><![CDATA[<p>The replication mechanism is very powerful and useful feature. Here I will try to briefly describe how to set it up.<br />
<span id="more-873"></span><br />
You can read more about replication <a href="http://en.wikipedia.org/wiki/Replication_(computer_science)#Database_replication" target="_blank">there</a>. To get to know more about replication format and which is more suitable for you read <a href="http://dev.mysql.com/doc/refman/5.1/en/replication-formats.html" target="_blank">this</a>.</p>
<p>There are different relationship type of replication which can be applied. Here I gonna set up MASTER&lt;-&gt;SLAVE scheme.</p>
<h3>MASTER</h3>
<p>These actions should be taken at master side. Go to <em>/etc/mysql</em>:</p>
<pre class="brush: bash; title: ; notranslate"> cd /etc/mysql </pre>
<p>And edit your mysql configuration file <em>my.cfg</em>:</p>
<pre class="brush: bash; title: ; notranslate">
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = monitoring
binlog_do_db = roundcube
binlog_do_db = information_schema
</pre>
<p>Here I defined 3 databases for replication: <em>monitoring</em>, <em>roundcube</em> and <em>information_schema</em>.<br />
Where directive <em>server-id</em> should be always be <strong>1</strong> for master host and &gt;1 for any other slave. Also to define more than one database for replication use directive <em>binlog_do_db</em> for each DB. <strong>Never ever</strong> try to put all database in one line and separate by comma or whatever(It is a trap I spent a lot of time doing this stuff:( ).</p>
<p>To replicate all databases from master skip variable <strong>binlog_do_db</strong>.</p>
<p>Restart your mysql when done:</p>
<pre class="brush: bash; title: ; notranslate">/etc/init.d/mysql restart</pre>
<p>Connect to your mysql master server:</p>
<pre class="brush: bash; title: ; notranslate">mysql -u root -p</pre>
<p>and run these mysql statements:</p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; CREATE USER 'repl'@'192.168.7.177' IDENTIFIED BY 'slavepass';
mysql&gt; GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.7.177';</pre>
<p>This two lines create new user <strong>repl</strong> with password <strong>slavepass</strong> allow it connects only from ip address <strong>192.168.7.177</strong>(set &#8216;%&#8217; instead of 192.168.7.177 if you want to open access for any host). And grand permission for that user to do replication operations.</p>
<pre class="brush: sql; title: ; notranslate">mysql&gt; FLUSH TABLES WITH READ LOCK;
mysql&gt; SHOW MASTER STATUS;</pre>
<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br />
| File                          | Position | Binlog_Do_DB                                                  | Binlog_Ignore_DB |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br />
| mysql-bin.000001 | 98            | monitoring,roundcube,information_schema |                                    |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</p>
<p>From these statements you need keep in mind value of <em>Position</em> it will be useful when you will run slave.</p>
<p>Before you run mysqlump you need to lock database(don&#8217;t close the session before backup done):</p>
<pre class="brush: sql; title: ; notranslate">mysql&gt;LOCK TABLES;</pre>
<p>And run mysqldump in another console window</p>
<pre class="brush: bash; title: ; notranslate">mysqldump --lock-all-tables -u root -p --databases monitoring, roundcube, informantion_scheman &gt;dbdump.db</pre>
<p>In case you have decided that you going to replicate all dbs:</p>
<pre class="brush: bash; title: ; notranslate">mysqldump --lock-all-tables -u root -p --all-databases &gt;dbdump.db</pre>
<p>Now you can unlock the database. To do it you can either close mysql session where you run <em>LOCK TABLES</em> (then tables will be automatically unlocked) or run:</p>
<pre class="brush: sql; title: ; notranslate">mysql&gt; UNLOCK TABLES;</pre>
<p>Then you are ready to transfer snapshot to slave host:</p>
<pre class="brush: bash; title: ; notranslate">scp dbdump.db user@slave:/tmp</pre>
<h3>SLAVE:</h3>
<p>The same actions with mysql config in <em>/etc/mysql</em>directory but slave side:</p>
<pre class="brush: bash; title: ; notranslate">server-id = 2
replicate-do-db = monitoring
replicate-do-db = roundcube
replicate-do-db = information_schema</pre>
<p>If you want replicate all databases skip variables <strong>replicate-do-db</strong>.<br />
Run mysql client and set up connection with master:</p>
<pre class="brush: bash; title: ; notranslate">mysql&gt; CHANGE MASTER TO
         MASTER_HOST='192.168.7.5',
         MASTER_USER='repl',
         MASTER_PASSWORD='slavepass',
         MASTER_LOG_FILE='mysql-bin.000001',
         MASTER_LOG_POS=98;</pre>
<p>Where,<br />
<strong>MASTER_HOST</strong> &#8211; ip or domain address of your master host.<br />
<strong>MASTER_USER</strong> &#8211; the name of user you created above.<br />
<strong>MASTER_PASSWORD</strong>- the password<br />
<strong>MASTER_LOG_FILE</strong> &#8211; field file from <em>SHOW MASTER STATUS</em> statement above.<br />
<strong>MASTER_LOG_POS</strong> the value from you <strong>Position</strong> field at <em>SHOW MASTER STATUS</em>.</p>
<p>And restart mysql:</p>
<pre class="brush: bash; title: ; notranslate">/etc/init.d/mysql restart</pre>
<h3>TESTING</h3>
<p>To check replication status run on slave:</p>
<pre class="brush: bash; title: ; notranslate">mysql&gt; show slave status \G </pre>
<p>And you get something like that:</p>
<pre class="brush: bash; title: ; notranslate">
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: xxx.xxx.xxx.xxx
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: bin-log.000463
          Read_Master_Log_Pos: 694544815
               Relay_Log_File: relay-log.001607
                Relay_Log_Pos: 130280711
        Relay_Master_Log_File: bin-log.000463
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 694544815
              Relay_Log_Space: 130280860
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
1 row in set (0.00 sec)
</pre>
<p>Most important position you got to check is <strong>Slave_IO_Running  </strong>and <strong>Slave_SQL_Running</strong> if one of then is <strong>No</strong> something is definetly wrong with your replication and you need to check variables <strong>Last_IO_Error</strong> and <strong>Last_SQL_Error</strong> for more details.</p>
<p>If both <strong>Slave_IO_Running  </strong>and <strong>Slave_SQL_Running</strong> are <strong>Yes</strong> than make some test changes(little data modification) at master in replicated database and value in <strong>Read_Master_Log_Pos</strong> should be increased in some way. If so than it works well.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2011/02/mysql-replication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MYSQL quick overview</title>
		<link>http://andriigrytsenko.net/2010/05/mysql-quick-overview/</link>
		<comments>http://andriigrytsenko.net/2010/05/mysql-quick-overview/#comments</comments>
		<pubDate>Tue, 18 May 2010 11:10:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=762</guid>
		<description><![CDATA[Here I systematized some of my MYSQL knowledges. First I decide to make some test database to do everything step-by-step. This will be companies database contains information about all employers, projects and departments. CREATE DATABASE company Go in: USE company And make 4 tables. Employers employer_id int primary key name varchar(15) surname varchar(25) hire_date date [...]]]></description>
			<content:encoded><![CDATA[<p>Here I systematized some of my MYSQL knowledges.<br />
<span id="more-762"></span></p>
<p>First I decide to make some test database to do everything step-by-step. This will be companies database contains information about all employers, projects and departments.</p>
<pre>CREATE DATABASE company</pre>
<p>Go in:</p>
<pre>USE company</pre>
<p>And make 4 tables.</p>
<table border="1">
<tbody></tbody>
<caption style="text-align: center;"><strong>Employers</strong></caption>
<tbody>
<tr>
<td>employer_id</td>
<td>int primary key</td>
</tr>
<tr>
<td>name</td>
<td>varchar(15)</td>
</tr>
<tr>
<td>surname</td>
<td>varchar(25)</td>
</tr>
<tr>
<td>hire_date</td>
<td>date</td>
</tr>
<tr>
<td>department_id</td>
<td>int</td>
</tr>
<tr>
<td>fired</td>
<td>int</td>
</tr>
</tbody>
</table>
<table border="1">
<tbody></tbody>
<caption style="text-align: center;"><strong>projects</strong></caption>
<tbody>
<tr>
<td>project_id</td>
<td>int primary key</td>
</tr>
<tr>
<td>name</td>
<td>varchar(255)</td>
</tr>
</tbody>
</table>
<table border="1">
<tbody></tbody>
<caption style="text-align: center;"><strong>departments</strong></caption>
<tbody>
<tr>
<td>department_id</td>
<td>int primary key</td>
</tr>
<tr>
<td>name</td>
<td>varchar(255)</td>
</tr>
</tbody>
</table>
<p>This table consists relation between employer and projects:</p>
<table border="1">
<tbody></tbody>
<caption><strong>project_involved</strong></caption>
<tbody>
<tr>
<td>employer_id</td>
<td>int</td>
</tr>
<tr>
<td>project_id</td>
<td>int</td>
</tr>
</tbody>
</table>
<p>Let&#8217;s create its in DB:</p>
<pre>CREATE TABLE employers (
employer_id int primary key auto_increment,
name varchar(15),
surname varchar(25),
hire_date date,
department_id int,
fired int);</pre>
<pre>CREATE TABLE projects (
project_id int primary key auto_increment,
name varchar(255));</pre>
<pre>CRETE TABLE departments (
department_id int primary key auto_increment,
name varchar(255));</pre>
<pre>CREATE TABLE project_involved (
employer_id int,
project_id int);</pre>
<p>And insert some data into them. I will show you only few of them:</p>
<pre>INSERT INTO projects (departments) VALUES ('General Project');</pre>
<p>In this insert I use <a href="http://dev.mysql.com/doc/refman/5.0/en/subqueries.html">subquery</a>:</p>
<pre>INSERT INTO employers
(name,surname,hire_date,department_id,fired)
VALUES ('Jonh','Smith','2007-10-30',
(SELECT department_id FROM departments WHERE name='Department A'),
0);</pre>
<p>Format of date should be the next:</p>
<p><strong><span style="color: #ff0000;">YYYY-MM-DD</span></strong></p>
<p>There is also some example of <strong>SELECT</strong> query in the <strong>UPDATE</strong> statement:</p>
<pre>INSERT INTO projects (name) VALUES ('General Project');</pre>
<pre>INSERT INTO project_involved (employer_id,project_id)
VALUES (
(SELECT employer_id FROM employers WHERE name='Jonh' AND surname='Smith'),
(SELECT project_id FROM projects WHERE name='General Project')
);</pre>
<p>In the ending of filling db up I&#8217;ve got next results:</p>
<pre>SELECT * FROM employers;
+-------------+------+---------+------------+---------------+-------+
| employer_id | name | surname | hire_date  | department_id | fired |
+-------------+------+---------+------------+---------------+-------+
|           1 | Jonh | Smith   | 2007-10-30 |             1 |     0 |
|           2 | Yan  | Brown   | 2008-11-23 |             2 |     0 |
+-------------+------+---------+------------+---------------+-------+
2 rows in set (0.00 sec)</pre>
<pre>SELECT * FROM project_involved;
+-------------+------------+
| employer_id | project_id |
+-------------+------------+
|           1 |          1 |
|        NULL |          2 |
+-------------+------------+
2 rows in set (0.00 sec)</pre>
<pre>SELECT * FROM projects;
+------------+-----------------+
| project_id | name            |
+------------+-----------------+
|          1 | General Project |
|          2 | Second Project  |
+------------+-----------------+
2 rows in set (0.00 sec)</pre>
<pre>SELECT * FROM departments;
+---------------+---------------+
| department_id | name          |
+---------------+---------------+
|             1 | departament A |
|             2 | departament B |
+---------------+---------------+
2 rows in set (0.00 sec)</pre>
<p>If you need to to remove something from your table(<em><span style="text-decoration: underline;">Department D</span></em> from <em><span style="text-decoration: underline;">departments</span></em> for example):</p>
<pre>DELETE FROM departments WHERE name='Department D';</pre>
<p>I&#8217;ve totally forgot about some column should be at <em><span style="text-decoration: underline;">employers</span></em> table. Column <span style="text-decoration: underline;"><em>position</em></span> has to be added. To change the structure of the table use <strong>ALTER</strong>:</p>
<pre>ALTER TABLE employers
ADD COLUMN position varchar(255) AFTER surname;</pre>
<p>in the same way you can remove needed column from the table:</p>
<pre>ALTER TABLE employers DROP COLUMN position;</pre>
<p>To rename column name run:</p>
<pre>ALTER TABLE table_name CHANGE old_name new_name INTEGER</pre>
<p>Now update the data:</p>
<pre>UPDATE employers SET position='system engineer'
WHERE surname='Smith' AND name='Jonh';</pre>
<p>There are few examples with subqueries. If you need to select all data from <em><span style="text-decoration: underline;">emloyers</span></em> table and resolve department name from <em><span style="text-decoration: underline;">departments</span></em> table. Run:</p>
<pre>SELECT employers.name, employers.surname, employers.hire_date, departments.name
FROM employers INNER JOIN departments USING (department_id);</pre>
<p>To simplify a query use <a href="http://www.google.com.ua/search?hl=en&amp;source=hp&amp;q=mysql+alias&amp;aq=f&amp;aqi=g10&amp;aql=&amp;oq=&amp;gs_rfai=">alias</a>:</p>
<pre>SELECT <span style="color: #ff0000;">e</span>.name, <span style="color: #ff0000;">e</span>.surname, <span style="color: #ff0000;">e</span>.hire_date, <span style="color: #ff0000;">d</span>.name FROM employers <span style="color: #ff0000;">e</span>
INNER JOIN departments <span style="color: #ff0000;">d</span> USING (department_id);
+------+---------+------------+---------------+
| name | surname | hire_date  | name          |
+------+---------+------------+---------------+
| Jonh | Smith   | 2007-10-30 | departament A |
| Yan  | Brown   | 2008-11-23 | departament C |
+------+---------+------------+---------------+
2 rows in set (0.00 sec)</pre>
<p>Here is more complex query which is involves all 4 tables:</p>
<pre>SELECT e.name, e.surname, e.position, e.hire_date, d.name department, p.name project
FROM projects p
INNER JOIN project_involved USING (project_id)
INNER JOIN employers e USING (employer_id)
INNER JOIN departments d USING (department_id);
+------+---------+-----------------+------------+---------------+-----------------+
| name | surname | position        | hire_date  | department    | project         |
+------+---------+-----------------+------------+---------------+-----------------+
| Jonh | Smith   | system engineer | 2007-10-30 | departament A | General Project |
| Jonh | Smith   | system engineer | 2007-10-30 | departament A | Second Project  |
+------+---------+-----------------+------------+---------------+-----------------+
2 rows in set (0.00 sec)</pre>
<p>To remove database or table use <strong>DROP</strong>:</p>
<pre>DROP [database|table]</pre>
<p>For example:</p>
<pre>DROP employers;</pre>
<p>To see database or table structure use <strong>SHOW CREATE</strong>:</p>
<pre>SHOW CREATE TABLE table;</pre>
<pre>SHOW CREATE DATABASE company;</pre>
<pre>SHOW CREATE DATABASE company;
+----------+--------------------------------------------------------------------+
| Database | Create Database                                                    |
+----------+--------------------------------------------------------------------+
| company  | CREATE DATABASE `company` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+----------+--------------------------------------------------------------------+</pre>
<h3 style="text-align: center;"><strong>BACKUPS</strong></h3>
<p>To make backups of your database use <strong>mysqldump</strong> :</p>
<pre>mysqldump -u root -p --database company &gt; company.sql</pre>
<p>To restores from backups :</p>
<pre>mysql -u root -p -e 'source company.sql' company</pre>
<p style="text-align: center;"><strong>CREATE USER</strong></p>
<pre>GRANT [privileges] ON [resource] TO [identity]</pre>
<p>In example I create user <em><span style="text-decoration: underline;">company_admin</span></em> which has  all privileges on all tables in database <span style="text-decoration: underline;"><em>company</em></span> from host <em><span style="text-decoration: underline;">localhost</span></em> with password <em><span style="text-decoration: underline;">secret-password</span></em>:</p>
<pre>GRANT ALL PRIVILEGES ON company.* TO company_admin@localhost
IDENTIFIED BY 'secret_password';</pre>
<p>There are some of the privileges, almost all of them is self-explained:</p>
<p><em>ALTER<br />
CREATE<br />
DELETE<br />
DROP<br />
GRANT<br />
INSERT<br />
SELECT<br />
UPDATE</em></p>
<p>For more details concerning <strong>GRANT</strong> go to <a href="http://dev.mysql.com/doc/refman/5.0/en/grant.html">ofdocs</a>.</p>
<p style="text-align: center"><strong>MYISAM VS INNODB</strong></p>
<p>InnoDB is set by default. And it&#8217;s speed and mature way to store simple data.</p>
<p>Advantages of InnoDB:</p>
<ol>
<li>transaction support</li>
<li>row-level locking</li>
<li>foreign key constraints</li>
</ol>
<p>To disadvantages we can attribute the next:</p>
<ol>
<li>don&#8217;t support full-text searching</li>
<li>some troubles with AUTO_INCREMENT columns</li>
</ol>
<p>To change of the table engine run:</p>
<pre>ALTER TABLE table ENGINE=[engine]</pre>
<pre>ALTER TABLE employers ENGINE=InnoDB</pre>
<p style="text-align: center;"><strong>FOREIGN KEY</strong></p>
<p>This feature help you to prevent your data from human mistake and keep it integrity.<br />
First, you need to convert your tables into InnoDB:</p>
<pre>ALTER TABLE table ENGINE=InnoDB;</pre>
<p>and set dependency:</p>
<pre>ALTER TABLE employers ADD CONSTRAINT dep_id_cons
FOREIGN KEY (department_id) REFERENCES departments (department_id);</pre>
<p>Now when we try to set employers.department_id which is not at departments.department_id. As result changes is not committed and we get an error:</p>
<pre>INSERT INTO employers (name,surname,department_id)
VALUES ('test','test','123');
ERROR 1452 (23000): Cannot add or update a child row:
a foreign key constraint fails (`company/employers`,
CONSTRAINT `dep_id_cons` FOREIGN KEY (`department_id`)
REFERENCES `departments` (`department_id`))</pre>
<p>To delete foreign key run:</p>
<pre>ALTER TABLE employers DROP FOREIGN KEY dep_id_cons;</pre>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/05/mysql-quick-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reset mysql password in several steps.</title>
		<link>http://andriigrytsenko.net/2009/08/reset-mysql-password-in-several-steps/</link>
		<comments>http://andriigrytsenko.net/2009/08/reset-mysql-password-in-several-steps/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 19:52:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=437</guid>
		<description><![CDATA[Make new password for mysql user in 5 simple steps. 1.Stop mysql server: #service mysql stop 2.Start in safe mode(use Ctrl+Z to send process to background): #/usr/bin/mysqld_safe --skip-grant-tables --user=root &#038; 3.Login as root: #mysql -u root 4.Make mysql execute next queries: UPDATE mysql.user SET Password=PASSWORD(’newpwd’) WHERE User=’root’; FLUSH PRIVILEGES; exit; Where newpwd is a new [...]]]></description>
			<content:encoded><![CDATA[<p>Make new password for mysql user in 5 simple steps.<br />
<span id="more-437"></span></p>
<p>1.Stop mysql server:</p>
<pre>#service mysql stop</pre>
<p>2.Start in safe mode(use <em>Ctrl+Z</em> to send process to background):</p>
<pre>#/usr/bin/mysqld_safe --skip-grant-tables --user=root &#038;</pre>
<p>3.Login as root:</p>
<pre>#mysql -u root</pre>
<p>4.Make mysql execute next queries:</p>
<pre>UPDATE mysql.user SET Password=PASSWORD(’newpwd’) WHERE User=’root’;
FLUSH PRIVILEGES;
exit;</pre>
<p>Where <em>newpwd</em> is a new password for mysql user &#8220;root&#8221;.<br />
5.Restart mysql:</p>
<pre>#service mysql restart</pre>
<p>Now you are ready to connect to server with new password.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/08/reset-mysql-password-in-several-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to print all tables at Oracle database.</title>
		<link>http://andriigrytsenko.net/2009/06/how-to-print-all-tables-at-oracle-database/</link>
		<comments>http://andriigrytsenko.net/2009/06/how-to-print-all-tables-at-oracle-database/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 14:58:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://localhost/?p=12</guid>
		<description><![CDATA[If you want to get all avaible tables in Oracle database you need a run this simple sql query: SQL> select table_name from user_tables order by table_name;]]></description>
			<content:encoded><![CDATA[<p>If you want to get all avaible tables in Oracle database you need a run this simple sql query: </p>
<p><span id="more-12"></span></p>
<pre>SQL> select table_name from user_tables order by table_name;</pre>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/06/how-to-print-all-tables-at-oracle-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Print space utilization at Oracle</title>
		<link>http://andriigrytsenko.net/2009/06/print-space-utilization-at-oracle/</link>
		<comments>http://andriigrytsenko.net/2009/06/print-space-utilization-at-oracle/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 14:48:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://localhost/?p=6</guid>
		<description><![CDATA[To print total and available space of Oracle database you can use next sql query. It&#8217;s a pretty good tool for monitoring. select t1.tablespace_name, t1.fs/1024/1024/1024 as free_space_GB, t2.ts/1024/1024/1024 as total_space_GB from (select tablespace_name,sum(bytes) as fs from dba_free_space group by tablespace_name) t1 join (select TABLESPACE_NAME,sum(BYTES) ts from dba_data_files group by TABLESPACE_NAME) t2 on t2.TABLESPACE_NAME=t1.TABLESPACE_NAME ; its [...]]]></description>
			<content:encoded><![CDATA[<p>To print total and available space of Oracle database you can use next sql query. It&#8217;s a pretty good tool for monitoring.</p>
<p><span id="more-6"></span></p>
<pre>select t1.tablespace_name, t1.fs/1024/1024/1024 as free_space_GB, t2.ts/1024/1024/1024 as total_space_GB
from (select tablespace_name,sum(bytes) as fs from dba_free_space group by tablespace_name) t1
join (select TABLESPACE_NAME,sum(BYTES) ts from dba_data_files group by TABLESPACE_NAME) t2
on t2.TABLESPACE_NAME=t1.TABLESPACE_NAME ;
</pre>
<p>its should be look like this:</p>
<pre>TABLESPACE_NAME                               FREE_SPACE_GB TOTAL_SPACE_GB
--------------------------------------------- ------------- --------------
BASDAT                                      87.7402954     325.765625
BASIDX                                      96.0326538     294.882813
RPTADMINDAT                               .488220215      .48828125
RPTADMINIDX                               .488220215      .48828125
RPTBASDAT                                  .488220215      .48828125
RPTBASIDX                                   .488220215      .48828125
RPTCBFDAT                                   .488220215      .48828125
RPTCBFIDX                                  .488220215      .48828125
SYSAUX                                     2.82495117              5
SYSTEM                                     29.7844849     30.5859375
UNDOTBS1                                   21.7189941     107.324219
USERS                                      4.55554199     5.27929688</pre>
<p>12 rows selected.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/06/print-space-utilization-at-oracle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

