Previous: MySQL installation (RPM installation mode) and directory structure
This article uses binary mode to install:
View the current system : File/sbin/init
The
Download MySQL website:
http://dev.mysql.com/downloads/mysql/(The current system is selected by default)
Http://dev.mysql.com/downloads/mirrors.html (Other mirror addresses)
Oracle Official Download: https://edelivery.oracle.com/
FTP Download: http://ftp.iij.ad.jp/pub/db/mysql/Downloads/
See so many, exactly download Which? Which is the binary package?
See Official Note: http://dev.mysql.com/doc/refman/5.1/en/binary-installation.html
Binary version format: mysql-version-os.tar.gz (eg: mysql-5.6.23-linux.tar.gz)
MySQL for the current example (size:289m) :
Http://ftp.iij.ad.jp/pub/db/mysql/Downloads/MySQL-5.6/mysql-5.6.23-linux-glibc2.5-i686.tar.gz
Decompression path:
cd/usr/local/src/
Tar zxvfmysql-5.6.23-linux-glibc2.5-i686.tar.gz
Move to directory/usr/local/and rename to MySQL:
MV Mysql-5.6.23-linux-glibc2.5-i686/usr/local/mysql
Add Users and Groups:
Groupadd MySQL
useradd-g MySQL MySQL
To set the owner and group of the MySQL directory:
Chown-r Mysql:mysql MySQL
Initialize MySQL:
/usr/local/mysql/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data
In the first and last red boxes, refer to the tips. Copy the service and configuration file into the system configuration file:
Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld
Cp/usr/local/mysql/support-files/my-default.cnf/etc/my.cnf
Edit the MySQL configuration file to add the following parameters: VI/ETC/MY.CNF
[Mysqld]
Basedir =/usr/local/mysql
DataDir =/usr/local/mysql/data
Port = 3306
server_id = 1
To start the MYSQLD service:
/etc/rc.d/init.d/mysqld start
Another way to start the MYSQLD service (see also tip):
/usr/local/mysql/bin/mysqld_safe&
#这是在Unix和NetWare中推荐启动mysqld服务的启动文件.
#更多参考: Mysqld_safe-mysql Server Startup Script
To set the root password for MySQL:
/usr/local/mysql/bin/mysqladmin-u root password ' mysql '
For security, use Mysql_secure_installation to set:
/usr/local/mysql/bin/mysql_secure_installation
# (content interception is as follows:)
Note:runningall PARTS of this SCRIPT are RECOMMENDED for all MySQL
SERVERS in PRODUCTION use! Please READ each STEP carefully!
............
entercurrent Password for root (enter for none): # If you have set Root password, enter it, or leave it blank
............
You alreadyhave a root password set and so can safely answer ' n '.
changethe root Password? [y/n] Y # do you want to change the root password? (because I've already set it up)
New Password:
Re-enter NewPassword:
............
removeanonymous users? [y/n] Y # Do you want to remove the anonymous user?
............
disallowroot login remotely? [y/n] Y # do you want to disable root login?
............
removetest database and access to it? [y/n] n # do you want to remove the test database?
............
reloadprivilege tables now? [y/n] Y # do you want to reload the permissions table?
............
Cleaning up ... #完成!
The socket file path for the client to communicate with the server after starting MySQL:
/tmp/mysql.sock
Log files are generated when you start the Mysqld service with Mysqld_safe:
/var/log/mysqld.log
Installation is almost complete!
Now remove MySQL (binary installation mode to delete all MySQL related files directly):
Rm-f/etc/init.d/mysqld
Rm-f/etc/my.cnf
Find/-namemysql #搜索mysql目录, then delete
Find/-name "mysql*" #先删除上面找出来的, and then find to continue to delete, note to do not delete!
MySQL installation (binary installation mode)