Thursday, May 27, 2004

Upgrading MySQL that ships with redhat 9 to MySQL 4 (4020)

Ok, here it is...
LEGEND: RED = COMMANDS , Navy Blue = Output, Green = Things you should change inside a command

Ok, you might want to go get a cup of cofee before you start, But maybe you should delay that, When you compile the MySQL code, the process is going to take probably a bit longer than 15 minutes, you can delay the cofee till then

I started the computer, Logged in as root ! Then i took the following steps

NOTE: If you have just installed REDHAT 9, This should work without reading, all you need is to copy the red text and execute it on the terminal window line by line, You should then be done...

Another NOTE: By The time you read this, I would have reinstalled REDHAT once again, and verified that it is step by step and correct... So our copy paste idea should work if you install RedHat FULLY and then come here to copy paste...

A VERY imprtant note: Backup your entier DB before you start, This can be done simply by doing the following
The line you see in red (command) might span 2 lines, it should copy normally and paste on one line, the directive --all-databases should include all your databases and all tables within them, in short this is more like a backup mysql till i install a new one

Open a terminal Window...
CD to the directory you want to store your backup file in
issue the following command
mysqldump --opt -u YOURUSERNAME --password="YOURPASSWORD" --all-databases > file.sql.bin

Instructions on restoring this at the bottom of this post

I dont know why it works when you add the .bin and lets you down when you have a very big DB and leave it .sql, either way, make sure the file is there and has all your databases (it should)

I downloaded the new MySQL source code from http://dev.mysql.com/downloads/ to a /root/Installs/ directory, The curent version was 4.0.20 (4020)

I unpacked the comressed package (MySQL Source) to a directory and then renamed it to mysql_src


Then i started by opening a terminal window (in GNOME)

Then navigated to the directory ( /root/Installs/mysql_src )

i did the following to display packages that depend on each other and uninstall them as follows.

First i ran

rpm -qa | grep -i mysql

This resulted in a list of MySQL related files

mysql-devel-3.23.54a-11

perl-DBD-MySQL-2.1021-3 (this one depended on mysql-3.23.54a-11)
libdbi-dbd-mysql-0.6.5-5
mysql-3.23.54a-11 (depended on mysql-server-3.23.54a-11 AND MyODBX-2.50.39.11)
MySQL-python-0.9.1-6
qt-MySQL-3.1.1-6
mod-auth-mysql-1.11.12
----------------------

Started uninstalling as follows

rpm -e mysql-devel-3.23.54a-11
rpm -e perl-DBD-MySQL-2.1021-3 (did not work, Needed to uninstall mysql-3.23.54a-11 first, But you go ahead, Skip this line or enter it, makes no difference, Just go step by step... This step did nothing and will be repeated forward in the text)
rpm -e libdbi-dbd-mysql-0.6.5-5
rpm -e mysql-3.23.54a-11 (Did not work as well, Will get back to it in a minute, Needed uninstall of qt-MySQL-3.1.1-6 and mod-auth-mysql-1.11.12 first)
rpm -e MySQL-python-0.9.1-6
rpm -e qt-MySQL-3.1.1-6
rpm -e mod-auth-mysql-1.11.12

So, we still have mysql-3.23.54a-11 and perl-DBD-MySQL-2.1021-3 to remove, The second needed the first to be removed and the first needed the following to be removed

So lets take out
mysql-server-3.23.54a-11
MyODBX-2.50.39.11
Than we can uninstall mysql-3.23.54a-11

rpm -e mysql-server-3.23.54a-11
rpm -e MyODBX-2.50.39.11

Now lets takle the remaining 2 out

rpm -e mysql-3.23.54a-11
rpm -e perl-DBD-MySQL-2.1021-3

Ok, we shoule be done, We run
rpm -qa | grep -i mysql
again and nothing appears, We are done Uninstalling our own MySQL



Great, So we have the source code of MySQL, We have uninstalled our outdated database and ready to install the database, if you are like i was 2 days ago, you might think compiling and building the database is hard, it is not its a piece of cake, just copy and paste the following red parts, If you are more experienced and wish to configure the directives yourself, go ahead, i dont think it counts much, When you do, check that the ./configure finished successfully, if not tweak the directives, if you lose hope, just copy and paste out directives again, Nothing changes on your system untill you run the MAKE command...




So now we need to make a usergroup called mysql and a user named mysql

Add Group mysql

groupadd mysql

Add User mysql
useradd -g mysql -c "MySQL Server" -d /dev/null -s /sbin/nologin mysql

Ok, I am assuming you have Changed Directory to the directory where you have the source code (in this example /root/Installers/mysql_src

The code you will see now has the directives i have chsen, To see your options you can execute the following

NOTE: At this point i have restarted my computer and loged in as root again, I am not sure if this step in necessary, But if you want to do it, Please bookmark this page so you an carry on where you left.

./configure --help | less
Now with the direcives i have chose, it would look like this

chown -R root.root *

./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --disable-maintainer-mode --with-mysqld-user=mysql --with-unix-socket-path=/tmp/mysql.sock --without-comment --without-debug --without-bench


Then hit enter key (they will have spanned multiple lines but that is OK (actually it is why we have the \ at the end of each line :))

This should take a few minutes, But the longer part is not this, it is yet to come (where you go get that cofee you wanted since the start)

First, We run the make clean to get rid of any old fies from the old install, it should take a minute or two.

make clean

Now, You can run the next line and go get the cofee

make && make install

You are neerly done, But still you have to configure MySQL for functional use and you have to restore that database you backed up at the start (if you did)

1- Installing a database on the database engine (Should create the data directory and tables for privilages and the default users

./scripts/mysql_install_db

Now there are a few nice instructions on that, You should take note of them, eventhough we will include them here...

Now we need to move the ownership of the newly installed MySQL directories to the new owner mysql

chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data

Now you should chose what kind of setup you need based on one factor, How large is the database this database engine is going to run ?

small, medium, large, OR huge

then you should copy one of the files - my-medium.cnf , my-small.cnf , my-large.cnf , my-huge.cnf to /etc/my.cnf

cp support-files/my-medium.cnf /etc/my.cnf
chown root:sys /etc/my.cnf
chmod 644 /etc/my.cnf

If you get an error message about the data directory missing
something has probably went wrong in the mysql_install_db step above.
Go back and review it, If in fact this is the case, Do that step ALONE again


Now lets load some settings into MySQL

echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
ldconfig



Now, we need MySQL Loaded whenever we reboot

cp ./support-files/mysql.server /etc/rc.d/init.d/mysql
chmod +x /etc/rc.d/init.d/mysql
/sbin/chkconfig --level 3 mysql on



Now, to make it runnable from anywhere on the command prompt

cd /usr/local/mysql/bin
for file in *; do ln -s /usr/local/mysql/bin/$file /usr/local/sbin/$file; done


now, Lets RUN MySQL (your nearly there)
cd ~
/etc/rc.d/rc3.d/S90mysql start



Now, we need to change the password for the root account, We also need to drop that root account that requiers no password (for security)

mysqladmin -u root password YOURNEWPASSWORD

mysql -u root -p

mysql> drop database test;
mysql> use mysql;
mysql> delete from db;
mysql> delete from user where not (host="localhost" and user="root");
mysql> flush privileges;



Now to quit (mysql) and return to shell ($), Type \q at the mysql prompt.

Now to restoring the database...

mysql -u root --password="YOURPASSWORD" < /path/to/xxx.sql.bin

2 Comments:

At 5:14 PM, Anonymous find webhosting said...

WEB HOSTING

Can I Help You.. Yes If you want to get on the web. If you want to start learning about creating a web site of your own.. go to http://webhost11.com. to find out more about find webhosting ... We can help find a web host for you.

 
At 10:50 PM, Anonymous Anonymous said...

If you always write interesting, I will be your regular reader. skin care Read a useful article about tramadol tramadol

 

Post a Comment

<< Home