1. Download, compile, and install
# Cd/usr/local/src/
# Wget http://mysql.byungsoo.net/Downloads/MySQL-5.1/mysql-5.1.38.tar.gz
# Tar-xzvf mysql-5.1.38.tar.gz ../software/
#./Configure
-- Prefix =/usr/local/mysql // MySQL installation directory
-- Datadir =/mydata // database storage directory
-- With-charset = utf8 // use UTF8 format
-- With-extra-charsets = complex // install all extended character sets
-- Enable-thread-safe-client // enable the secure thread of the client
-- With-big-tables // enable large tables
-- With-ssl // use SSL encryption
-- With-embedded-server // compile to embedded MySQL library (libmysqld. ),
-- Enable-local-infile // allow local data import
-- Enable-Cycler // compile common operators of x86 to improve performance
-- With-plugins = innobase // database plug-in
-- With-plugins = partition // table sharding function, which splits a large table into multiple small tables
# Make & make install // compile and install
2. Create users and groups
# Groupadd mysql // create a MySQL Group
# Useradd-g mysql-s/sbin/nologin mysql // create a MySQL user to belong to the MySQL Group
Iii. Configuration
# Chown-R mysql: mysql/usr/local/mysql/grant MySQL directory permissions to MySQL users and groups
# Cp/usr/local/src/software/mysql-5.1.38/support-files/my-medium.cnf/etc/my. cnf // configure file my. cnf
#/Usr/local/mysql/bin/mysql_install_db -- user = mysql // use MySQL to initialize the database
# Chown-R mysql: mysql/usr/local/mysql/var // give the initialized database directory to the MySQL owner
#/Usr/local/mysql/bin/mysqld_safe -- user = mysql & // start MySQL
4. Others
# Cp/usr/local/src/software/mysql-5.1.38/support-files/mysql. server/etc/init. d/mysqld
# Chmod 755/etc/init. d/mysqld
# Chkconfig -- add mysqld
# Chkconfig mysqld on
# Service mysqld restart
V. login Test
# Cd/usr/local/mysql/bin
# Mysql
> Show databases;
#
End of MySQL Installation
How to configure mysql in linux
In linux, the mysql configuration file path is under/usr/share/mysql.
Files are: my-huge.cnf, my-large.cnf, my-medium, my-small.cnf
Open one of these files as needed:
Find [mysqld] in the file
In the next line, add datadir = FILEPATH/* to the path where the database is stored */
Save the file
Input in shell
# Cp my-***. cnf/etc
# Cd/etc
# Mv my. cnf my. cnf. bak/* back up the previous mysql configuration file in the system */
# Mv my-***. cnf my. cnf
# Service mysqld start/* start mysql service */
# Ntsysv/* configure mysql to start automatically. In the pop-up window, select the mysqld service with a space and click "save */