<?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>RedHatVN Network &#187; mysql</title>
	<atom:link href="http://redhatvn.net/tag/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://redhatvn.net</link>
	<description>Shared Linux problems</description>
	<lastBuildDate>Tue, 07 Sep 2010 08:08:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>List of Basic MySQL Commands</title>
		<link>http://redhatvn.net/list-of-basic-mysql-commands</link>
		<comments>http://redhatvn.net/list-of-basic-mysql-commands#comments</comments>
		<pubDate>Fri, 15 Jan 2010 05:03:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Cpanel]]></category>
		<category><![CDATA[Directadmin]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://redhatvn.net/?p=1074</guid>
		<description><![CDATA[This is a list of handy MySQL commands that I use time and time again. At the bottom are statements, clauses, and functions you can use in MySQL. Below that are PHP and Perl API functions you can use to interface with MySQL. To use those you will need to build PHP with MySQL functionality. [...]]]></description>
			<content:encoded><![CDATA[<p>This is a list of handy MySQL commands that I use time and time again. At the bottom are statements, clauses, and functions you can use in MySQL. Below that are PHP and Perl API functions you can use to interface with MySQL. To use those you will need to build PHP with MySQL functionality. To use MySQL with Perl you will need to use the Perl modules DBI and DBD::mysql.<br />
<span id="more-1074"></span><br />
Below when you see # it means from the unix shell. When you see mysql&gt; it means from a MySQL prompt after logging into MySQL.</p>
<h4>To login (from unix shell) use -h only if needed.</h4>
<p><code># [mysql dir]/bin/mysql -h hostname -u root -p</code></p>
<h4>Create a database on the sql server.</h4>
<p><code>mysql&gt; create database [databasename];</code></p>
<h4>List all databases on the sql server.</h4>
<p><code>mysql&gt; show databases;</code></p>
<h4>Switch to a database.</h4>
<p><code>mysql&gt; use [db name];</code></p>
<h4>To see all the tables in the db.</h4>
<p><code>mysql&gt; show tables;</code></p>
<h4>To see database’s field formats.</h4>
<p><code>mysql&gt; describe [table name];</code></p>
<h4>To delete a db.</h4>
<p><code>mysql&gt; drop database [database name];</code></p>
<h4>To delete a table.</h4>
<p><code>mysql&gt; drop table [table name];</code></p>
<h4>Show all data in a table.</h4>
<p><code>mysql&gt; SELECT * FROM [table name];</code></p>
<h4>Returns the columns and column information pertaining to the designated  table.</h4>
<p><code>mysql&gt; show columns from [table name];</code></p>
<h4>Show certain selected rows with the value “whatever”.</h4>
<p><code>mysql&gt; SELECT * FROM [table name] WHERE [field name] =  "whatever";</code></p>
<h4>Show all records containing the name “Bob” AND the phone number  ‘3444444′.</h4>
<p><code>mysql&gt; SELECT * FROM [table name] WHERE name = "Bob" AND  phone_number = '3444444';</code></p>
<h4>Show all records not containing the name “Bob” AND the phone number  ‘3444444′ order by the phone_number field.</h4>
<p><code>mysql&gt; SELECT * FROM [table name] WHERE name != "Bob" AND  phone_number = '3444444' order by phone_number;</code></p>
<h4>Show all records starting with the letters ‘bob’ AND the phone number  ‘3444444′.</h4>
<p><code>mysql&gt; SELECT * FROM [table name] WHERE name like "Bob%" AND  phone_number = '3444444';</code></p>
<h4>Show all records starting with the letters ‘bob’ AND the phone number  ‘3444444′ limit to records 1 through 5.</h4>
<p><code>mysql&gt; SELECT * FROM [table name] WHERE name like "Bob%" AND  phone_number = '3444444' limit 1,5;</code></p>
<h4>Use a regular expression to find records. Use “REGEXP BINARY” to force case-sensitivity. This finds any record beginning with a.</h4>
<p><code>mysql&gt; SELECT * FROM [table name] WHERE rec RLIKE "^a";</code></p>
<h4>Show unique records.</h4>
<p><code>mysql&gt; SELECT DISTINCT [column name] FROM [table name];</code></p>
<h4>Show selected records sorted in an ascending (asc) or descending  (desc).</h4>
<p><code>mysql&gt; SELECT [col1],[col2] FROM [table name] ORDER BY  [col2] DESC;</code></p>
<h4>Return number of rows.</h4>
<p><code>mysql&gt; SELECT COUNT(*) FROM [table name];</code></p>
<h4>Sum column.</h4>
<p><code>mysql&gt; SELECT SUM(*) FROM [table name];</code></p>
<h4>Join tables on common columns.</h4>
<p><code>mysql&gt; select lookup.illustrationid,  lookup.personid,person.birthday from lookup left join person on  lookup.personid=person.personid=statement to join birthday in person table with  primary illustration id;</code></p>
<h4>Creating a new user. Login as root. Switch to the MySQL db. Make the user.  Update privs.</h4>
<p><code># mysql -u root -p<br />
mysql&gt; use mysql;<br />
mysql&gt; INSERT  INTO user (Host,User,Password)  VALUES('%','username',PASSWORD('password'));<br />
mysql&gt; flush privileges;</code></p>
<h4>Change a users password from unix shell.</h4>
<p><code># [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org  -p password 'new-password'</code></p>
<h4>Change a users password from MySQL prompt. Login as root. Set the password.  Update privs.</h4>
<p><code># mysql -u root -p<br />
mysql&gt; SET PASSWORD FOR  'user'@'hostname' = PASSWORD('passwordhere');<br />
mysql&gt; flush privileges;</code></p>
<h4>Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.</h4>
<p><code># /etc/init.d/mysql stop<br />
# mysqld_safe --skip-grant-tables  &amp;<br />
# mysql -u root<br />
mysql&gt; use mysql;<br />
mysql&gt; update user set  password=PASSWORD("newrootpassword") where User='root';<br />
mysql&gt; flush  privileges;<br />
mysql&gt; quit<br />
# /etc/init.d/mysql stop<br />
# /etc/init.d/mysql  start</code></p>
<h4>Set a root password if there is on root password.</h4>
<p><code># mysqladmin -u root password newpassword</code></p>
<h4>Update a root password.</h4>
<p><code># mysqladmin -u root -p oldpassword newpassword</code></p>
<h4>Allow the user “bob” to connect to the server from localhost using the password “passwd”. Login as root. Switch to the MySQL db. Give privs. Update privs.</h4>
<p><code># mysql -u root -p<br />
mysql&gt; use mysql;<br />
mysql&gt; grant  usage on *.* to bob@localhost identified by 'passwd';<br />
mysql&gt; flush  privileges;</code></p>
<h4>Give user privilages for a db. Login as root. Switch to the MySQL db. Grant  privs. Update privs.</h4>
<p><code># mysql -u root -p<br />
mysql&gt; use mysql;<br />
mysql&gt; INSERT  INTO user  (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv)  VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');<br />
mysql&gt;  flush privileges;</code></p>
<p>or</p>
<p><code>mysql&gt; grant all privileges on  databasename.* to username@localhost;<br />
mysql&gt; flush privileges;</code></p>
<h4>To update info already in a table.</h4>
<p><code>mysql&gt; UPDATE [table name] SET Select_priv = 'Y',Insert_priv  = 'Y',Update_priv = 'Y' where [field name] = 'user';</code></p>
<h4>Delete a row(s) from a table.</h4>
<p><code>mysql&gt; DELETE from [table name] where [field name] =  'whatever';</code></p>
<h4>Update database permissions/privilages.</h4>
<p><code>mysql&gt; flush privileges;</code></p>
<h4>Delete a column.</h4>
<p><code>mysql&gt; alter table [table name] drop column [column  name];</code></p>
<h4>Add a new column to db.</h4>
<p><code>mysql&gt; alter table [table name] add column [new column name]  varchar (20);</code></p>
<h4>Change column name.</h4>
<p><code>mysql&gt; alter table [table name] change [old column name]  [new column name] varchar (50);</code></p>
<h4>Make a unique column so you get no dupes.</h4>
<p><code>mysql&gt; alter table [table name] add unique ([column  name]);</code></p>
<h4>Make a column bigger.</h4>
<p><code>mysql&gt; alter table [table name] modify [column name]  VARCHAR(3);</code></p>
<h4>Delete unique from table.</h4>
<p><code>mysql&gt; alter table [table name] drop index [colmn name];</code></p>
<h4>Load a CSV file into a table.</h4>
<p><code>mysql&gt; LOAD DATA INFILE '/tmp/filename.csv' replace INTO  TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'  (field1,field2,field3);</code></p>
<h4>Dump all databases for backup. Backup file is sql commands to recreate all  db’s.</h4>
<p><code># [mysql dir]/bin/mysqldump -u root -ppassword --opt  &gt;/tmp/alldatabases.sql</code></p>
<h4>Dump one database for backup.</h4>
<p><code># [mysql dir]/bin/mysqldump -u username -ppassword --databases  databasename &gt;/tmp/databasename.sql</code></p>
<h4>Dump a table from a database.</h4>
<p><code># [mysql dir]/bin/mysqldump -c -u username -ppassword  databasename tablename &gt; /tmp/databasename.tablename.sql</code></p>
<h4>Restore database (or database table) from backup.</h4>
<p><code># [mysql dir]/bin/mysql -u username -ppassword databasename  &lt; /tmp/databasename.sql</code></p>
<h4>Create Table Example 1.</h4>
<p><code>mysql&gt; CREATE TABLE [table name] (firstname VARCHAR(20),  middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid  VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone  VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail  VARCHAR(255));</code></p>
<h4>Create Table Example 2.</h4>
<p><code>mysql&gt; create table [table name] (personid int(50) not null  auto_increment primary key,firstname varchar(35),middlename  varchar(50),lastnamevarchar(50) default 'bato');</code><br />
Source: http://www.pantz.org/</p>
]]></content:encoded>
			<wfw:commentRss>http://redhatvn.net/list-of-basic-mysql-commands/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>How to retrieve data from mysql using bash script</title>
		<link>http://redhatvn.net/how-to-retrieve-data-from-mysql-using-bash-script</link>
		<comments>http://redhatvn.net/how-to-retrieve-data-from-mysql-using-bash-script#comments</comments>
		<pubDate>Fri, 22 Jan 2010 08:53:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[shell script]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://redhatvn.net/?p=1114</guid>
		<description><![CDATA[Besides from using perl scripts, phpmyadmin and customized php pages, here is a quick way to fetch data from mysql database using shell script. Just make sure you are currently running mysql from your box with existing database and table inside. First, launch your favorite linux editor and create a bash script and paste the [...]]]></description>
			<content:encoded><![CDATA[<p>Besides from using perl scripts, phpmyadmin and  customized php pages, here is a quick way to fetch data from mysql  database using shell script.</p>
<p>Just make sure you are currently running mysql from your box with  existing database and table inside.<br />
<span id="more-1114"></span><br />
First, launch your favorite linux editor and create a bash script and  paste the following bash codes inside and save.</p>
<blockquote><p>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
#!/bin/bash<br />
# july 03 2007 – vertito<br />
# this script retrieves data from mysql using bash</p>
<p>dbase=`mysql -uMYSQLUSENAME -pMYSQLPASSWORD -e”use MYDATABASE; select  * from MYTABLE where id = 1;”`<br />
for data in $dbase ;<br />
do<br />
echo $data<br />
done</p>
<p>echo Done.<br />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</p></blockquote>
<p>#chmod 700 yourscript.sh<br />
#./yourscript.sh</p>
<p>works like a charm!</p>
<p>Dont forget to change the following wordings:</p>
<p>MYSQLUSERNAME = your mysql username access with your mysql server<br />
MYSQLPASSWORD = your mysql password<br />
MYDATABASE = your running mysql database name<br />
MYTABLE = your selected table name</p>
]]></content:encoded>
			<wfw:commentRss>http://redhatvn.net/how-to-retrieve-data-from-mysql-using-bash-script/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to change the mysql port</title>
		<link>http://redhatvn.net/how-to-change-the-mysql-port</link>
		<comments>http://redhatvn.net/how-to-change-the-mysql-port#comments</comments>
		<pubDate>Fri, 15 Jan 2010 04:49:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Cpanel]]></category>
		<category><![CDATA[Directadmin]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://redhatvn.net/?p=1072</guid>
		<description><![CDATA[To change the port, select the “my.cnf file. Change it to whatever you like and remove the # from the front. Then restart the engine and you should be set for that. Open /etc/my.cnf file: # vi /etc/my.cnf Set new port 5123: port=5123 Here is is my sample /etc/my.cnf file: [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock port=5123 old_passwords=1 [...]]]></description>
			<content:encoded><![CDATA[<p>To change the port, select the “my.cnf file.</p>
<p>Change it to whatever you like and remove the # from the front. Then restart the engine and you should be set for that.</p>
<p><strong>Open /etc/my.cnf file:</strong></p>
<p><code><strong># vi /etc/my.cnf</strong></code></p>
<p>Set new port 5123:<br />
<code>port=5123</code><br />
Here is is my sample /etc/my.cnf file:</p>
<blockquote><p>[mysqld]<br />
datadir=/var/lib/mysql<br />
socket=/var/lib/mysql/mysql.sock<br />
port=5123<br />
old_passwords=1<br />
bind = 203.171.31.11
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://redhatvn.net/how-to-change-the-mysql-port/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Backup Databases in MySQL</title>
		<link>http://redhatvn.net/backup-databases-in-mysql</link>
		<comments>http://redhatvn.net/backup-databases-in-mysql#comments</comments>
		<pubDate>Mon, 04 Jan 2010 07:33:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Cpanel]]></category>
		<category><![CDATA[Directadmin]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://redhatvn.net/?p=1039</guid>
		<description><![CDATA[How about backing up all the databases in the server? That’s an easy one, just use the –all-databases parameter to backup all the databases in the server in one step. mysqldump –all-databases&#62; alldatabases.sql How to Backing up only the Database Structure in MySQL You can backup only the database structure by telling mysqldump not to [...]]]></description>
			<content:encoded><![CDATA[<p>How about backing up all the databases in the server? That’s an easy one, just use the –all-databases parameter to backup all the databases in the server in one step.</p>
<blockquote dir="ltr"><p><code>mysqldump –all-databases&gt; alldatabases.sql</code></p></blockquote>
<p>How to Backing up only the Database Structure in MySQL<br />
You can backup only the database structure by telling mysqldump not to back up the data. You can do this by using the –no-data parameter when you call mysqldump.</p>
<blockquote dir="ltr"><p><code>mysqldump –no-data –databases Customers Orders Comments &gt; structurebackup.sql</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://redhatvn.net/backup-databases-in-mysql/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ODBC support on a cPanel server</title>
		<link>http://redhatvn.net/odbc-support-on-a-cpanel-server</link>
		<comments>http://redhatvn.net/odbc-support-on-a-cpanel-server#comments</comments>
		<pubDate>Fri, 25 Dec 2009 05:51:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Cpanel]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://redhatvn.net/?p=965</guid>
		<description><![CDATA[How to compile unix odbc on a cPanel server? On a cPanel server, the /scripts/easyapache script almost provides all the modules that are required to host the websites but the modules such as odbc has to be installed manually. You first have to install the devel packages for unixodbc, then add a line in rawopts [...]]]></description>
			<content:encoded><![CDATA[<p><strong>How to compile unix odbc on a cPanel server?</strong> On a cPanel server, the /scripts/easyapache script almost provides all the modules that are required to host the websites but the modules such as odbc has to be installed manually. <strong>You first have to install the devel packages for unixodbc, then add a line in rawopts file and rebuild Apache+PHP.</strong> That is it.<br />
<span id="more-965"></span><br />
<strong>1. Install the UnixODBC devel packages:</strong></p>
<blockquote><p><strong><code>yum install unixODBC unixODBC-devel</code></strong></p></blockquote>
<p><strong>2. You now need to create a file “all_php5″ to add a line to enable odbc so that apache build will pick it up from there. File all_php5 is for PHP5 and all_php4 is for PHP4.</strong></p>
<blockquote><p><strong><code>nano /var/cpanel/easy/apache/rawopts/all_php5</code></strong></p></blockquote>
<p><strong>3. Add the following line:</strong></p>
<blockquote><p><span style="color: #ff6600;"><strong>–with-unixODBC=/usr</strong></span></p></blockquote>
<p><strong>4. Rebuild Apache/PHP using the “easyapache” script and the above file will be picked up automatically:</strong></p>
<blockquote><p><strong><code>/scripts/easyapache</code></strong></p></blockquote>
<p>Once the compilation completes, you should have odbc module compiled with PHP. <strong>You can check the module either using a phpinfo() file OR through shell by executing:</strong></p>
<blockquote><p><strong><code>php -i | grep odbc</code></strong></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://redhatvn.net/odbc-support-on-a-cpanel-server/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->