3 ways to install mysql
- # yum install mysql mysql-server
- # rpm -ivh MySQL-client-5.6.23-1.linux_glibc2.5.i386.rpm MySQL-server-5.6.23-1.linux_glibc2.5.i386.rpm
- install by binary file (may need to install cmake gcc gcc-c++ ncurses first):
a. # tar xvf mysql-5.6.23.tar.gz -C /usr/src
b. # cd /usr/src/mysql-5.6.23
c. # cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON
d. # make j2
e. # make install
note: options of cmake please refer to official docs
after installation, set up the configuration files (if use default configuration, jump to start mysql and set up password).
# vim /etc/my.cnf
[mysqld]
datadir=/data
user=mysql
socket=/data/mysqld.sock
skip-name-resolve
port=3306
log-bin=/data/mysqld-bin
log-bin-index=/data/mysql-bin
server-id=1
[mysqld_safe]
log-error=/data/mysqld.err
pid-file=/data/mysqld.pid
make directory and initiate
# rm -rf /data
# mkdir /data
# cd /usr/local/mysql
# ./scripts/mysql_install_db --datadir=/data --user=mysql
start mysql and set up password
# mysqld_safe --defaults-file=/etc/my.cnf &
or
# cp ./support-files/mysql.server /etc/rc.d/init.d/sql
# chmod 755 /etc/rc.d/init.d/sql
# service sql start
# mysqladmin -u root -S /data/mysqld.sock password ‘123‘
# mysqladmin -u root -h 127.0.0.1 -P 3306 password ‘123‘
or
# ln -s /data/mysqld.sock /tmp/mysql.sock
# mysql_secure_installation
# rm -rf /tmp/mysql.sock
login mysql
# mysql -u root -S /data/mysqld.sock
or
# mysql -u root -h 127.0.0.1 -P3306