How to install Mysql in linux server
[Precondition]
OS : Redhat Fedora 2
Mysql : 3.23.54
Mysql is a very outstanding software of database, and it is free too. Many websites of Internet are making full use of it combined with PHP, Ruby, Perl and so on. So how to install correctly in linux server will become more and more important. There are good articles or manuals to introduce howto in Internet. With the help of the warmhearted, I have installed and updated Mysql from version 3.23.54 to version 5.0.19. This chapter will mainly focus on how to install and update it basing on old version of mysql.
If you are a beginner of mysql, I suggest that you had better firstly study tutorial of mysql. A good website is http://dev.mysql.com/ which is stored some material and manuals for beginner.
[How to install new version of mysql]
Please refer to Tips to download relative mysql software. Here, I guess that we have acquired mysql-standard-5.0.19-linux-i686.tar.gz.
1) Add a login user and group fro ‘mysqld’ to run. If system has existed
relative user name and group name, these operations will be skipped.
Of course, if you do it again, it is no problems.
$groupadd mysql
$useradd –g mysql mysql
2) Unpack mysql-standard-5.0.19-linux-i686.tar.gz into /usr/local directory
#cd /usr/local
#tar xvzf ./mysql-standard-5.0.19-linux-i686.tar.gz ./
#ln ./ mysql-standard-5.0.19-linux-i686 ./mysql
3) Install MySQL
#cd ./mysql
#scripts/mysql_install_db --user=mysql
4) Backup old MySQL’s configuration and commands
#mv /etc/my.cnf /etc/old_cnf
#mv /etc/init.d/mysqld /etc/init.d/old_mysqld
#cp –rf /usr/bin /usr/old_bin
#cd /usr/bin
#rm my*
#rm my*.*
5) Configure new MySQL. There are four configuring files at less in
the support-files directory.
‘my-huge.cnf’ for huge database
‘my-large.cnf’ for large database
‘my-medium.cnf’ for medium database
‘my-small.cnf’ for small database
‘my-innodb-heavy-4G.cnf’ for innodb database, in normal case, innodb
will be forbidden. If you are interested in it, please visit ]
http://www.innodb.com/index.php to realise more information in details.
#cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
#vim /etc/my.cnf
//set basedir=/usr/local/mysql
//set datadir=/usr/local/mysql/data
#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
6) Change the ownership of program binaries to `root' and ownership
of the ‘data’ directory to the user that you run `mysqld' as.
Assuming that you are located in the installation directory
(`/usr/local/mysql'), the commands look like this:
#chown -R root .
#chown -R mysql data
#chgrp -R mysql .
7) Add the directory of MySQL into $PATH envorinment.
Edit ~/.bash_profile and append the following line.
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
8) Reboot linux
#reboot
[Tips]
Where to download the lastest version of mysql?
You can visit http://dev.mysql.com/downloads/ to find the latest version of mysql to download it. mysql-standard-5.0.19-linux-i686.tar.gz is download from http://dev.mysql.com/downloads/mysql/5.0.html below the tag of ‘Linux(non RPM package)downloads(platform notes)’. If your CPU and HDD are faster and larger, the maximum one is the better choice. Some persons like DIY(Do It By yourself), and ‘Source downloads’ tag should be hot point for them. I am long-winded man, and DIYs had better read README carefully before compiling and installing. If they are unfavor to read English, I recommend a website: http://www.chinaunix.net/jh/17/178508.html which is very good for beginner to configure and install mysql. I hope that it will exist when you visit it!
How to query current RPM package of mysql?
# rpm -qa | egrep 'mysql'
mysql-jdbc-3.0.8-2
mysql-server-3.23.58-9
php-mysql-4.3.4-11
mysql-devel-3.23.58-9
freeradius-mysql-0.9.3-4
libdbi-dbd-mysql-0.6.5-8.1
mysql-3.23.58-9
mysql-jdbc-tomcat-3.0.8-2
mod_auth_mysql-20030510-4.1
mysql-bench-3.23.58-9
How to uninstall RPM package?
Please use the following command, ‘-e’ means erasing operation. ‘nodeps’ means not to check dependencies before uninstalling the packages, and it is forced.
#rpm {-e|--erase} [--allmatches] [--nodeps] [--noscripts] [--notriggers] [--repackage] [--test] PACKAGE_NAME ...
If you want to know more details about ‘rpm’ command, please use #man rpm or #info rmp to obtain more information.
How to start/stop/restart mysql server?
#service mysqld start/stop/restart
How to change ‘mysql.sock’ into other directory?
#cd /etc
#vi my.cnf
Modify ‘sokcet’ key’s value, for example:
[client]
socket = /var/lib/mysql/mysql.sock
[mysqld]
socket = /var/lib/mysql/mysql.sock
Generate ‘mysql.sock’ file and relative directories
#service mysqld restart
#cd /var/lib
Change group from ‘root’ to ‘mysql’
#chgrp mysql ./mysql
Make other groups can connect mysql server by ‘mysql.sock’
#chmod +x ./mysql
[User Manual For Mysql 5.0]
http://dev.mysql.com/doc/refman/5.0/en/index.html