{{keywords>mybook world edition linux ssh mysql groupadd useradd chmod wget gunzip configure make install chown chgrp mysql_install_db ldd echo ldconfig mysqld_safe ln mysqladmin sql}}
====== Install MySQL ======
First consider fallowing all the previous steps the [[home|WD MyBook World Edition Hacks]] tutorial
Please read the official MySQL documentation before proceeding. [[http://dev.mysql.com/doc/refman/5.0/en/installing-source.html|MySQL Installation Using a Source Distribution]]
* Add a login user and group for mysqld.
# groupadd mysql
# useradd -g mysql mysql
* Be sure that /tmp directory can be accessed by mysql user.
# chmod -R 777 /tmp
* Choose a directory to unpack the distribution.
# cd /tmp
* Download distribution file. [[http://dev.mysql.com/doc/refman/5.0/en/getting-mysql.html|How to Get MySQL]]
# wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.51.tar.gz/from/http://ftp.astral.ro/mirrors/mysql.com/
* Rename downloaded file.
# mv index.html mysql-5.0.51.tar.gz
* Uncompress source archive.
# gunzip < mysql-5.0.51.tar.gz | tar xvf -
* Change the location in unpacked distribution directory.
# cd mysql-5.0.51
* Configure the release and compile everything [[http://dev.mysql.com/doc/refman/5.0/en/configure-options.html|Typical configure Options]]
# ./configure --prefix=/usr/local/mysql --with-low-memory
# make
* Install the distribution.
# make install
* Setup an option file.
# cp support-files/my-medium.cnf /etc/my.cnf
* Change location in the installation directory.
# cd /usr/local/mysql
* Assign mysql user and group to installed files.
# chown -R mysql .
# chgrp -R mysql .
* Create the mysql data directory and initialize the grant tables.
# bin/mysql_install_db --user=mysql
* Add shared libraries and mysql library path.
# ldd /usr/local/mysql/bin/mysql
# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
# ldconfig
* Assing mysql user to data directory.
# chown -R root .
# chown -R mysql var
* Start mysql server.
# bin/mysqld_safe --user=mysql &
* To start mysql server automaticaly when device is started:
# cp support-files/mysql.server /etc/init.d/mysql
# chmod +x /etc/init.d/mysql
# ln -s /etc/init.d/mysql /etc/init.d/S40mysql
* Test mysql server. [[http://dev.mysql.com/doc/refman/5.0/en/post-installation.html|Post-Installation Setup and Testing]]
# bin/mysqladmin version
# bin/mysqladmin variables
# bin/mysqlshow
# bin/mysqlshow mysql
# less /etc/my.cnf
* Login to the mysqlserver and set root password.
# bin/mysql
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
SET PASSWORD FOR 'root'@'HOST_NAME' = PASSWORD('newpwd');
SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');
DROP USER '';
DROP USER ''@'localhost';
DROP USER ''@'HOST_NAME';