1. Preparatory work
① official website Download: https://dev.mysql.com/downloads/mysql/5.6.html#downloads
Uploaded to the server after download.
② creating a Linux group user
Groupadd MySQL
useradd-g MySQL MySQL
2. Installation
① decompression, such as put into the/usr/local/, into the directory, the use of Z unzip the GZ package, and then renamed to the MySQL folder.
[Email protected] ~]# cd/usr/local/
[[email protected] local] TAR-XZVF mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz
[[email protected] local] MV mysql-5.6.41-linux-glibc2.12-x86_64 MySQL
② set MySQL directory belong to the main group are added to the above group and user MySQL
[[email protected] local] chown-r mysql.mysql MySQL
③ Installation and Configuration
[[email protected] local] CD MySQL
[Email protected] mysql]./scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/usr/local/ mysql/data/
Note: If you perform the last command above, the following issues occur:
FATAL Error:please Install the following Perl modules before executing./scripts/mysql_install_db:data::D umper
Workaround: Install the autoconf Library
Command: Yum-y install autoconf//This package will be installed when the Data:dumper module installation is complete re-executing the last command above
3. Configuration
① configuration my.cnf, you can copy or the next, inside the parameter file path to.
[[email protected] MySQL] CP support-files/my-default.cnf/etc/my.cnf
[[email protected] MySQL] vim/etc/my.cnf
[MySQL] # set MySQL client default character set Default-character-set=utf8 Socket=/var/lib/mysql/mysql.sock [mysqld] Skip-name-resolve #设 3306 Ports port = 3306 Socket=/var/lib/mysql/mysql.sock # set up MySQL installation directory Basedir=/usr/local/mysql # Set the data storage directory for MySQL database D Atadir=/usr/local/mysql/data ② Configuring Startup Items
[email protected] mysql]# CP./support-files/mysql.server/etc/rc.d/init.d/mysqld
[Email protected] mysql]# chmod +x/etc/rc.d/init.d/mysqld #添加执行权限
[Email protected] mysql]# chkconfig--add mysqld #加入到系统服务
[[email protected] mysql]# chkconfig--list mysqld #检查是否生效, you can control the start and stop with service command after effective
[Email protected] mysql]# service mysqld start #启动mysql
4. Environment variable Configuration
#能正常启动服务, unable to log in, need to configure environment variables
[Email protected] mysql]# vim ~/.bash_profile
Export path= $PATH:/usr/local/mysql/bin #文件最后添加这一句, point to your installation directory bin, save exit
[Email protected] mysql]# source ~/.bash_profile #立即生效
5. Test log in to MySQL again and the discovery will be successful.
[[email protected] mysql]mysql #直接mysql就能进入, or initialize settings.
[Email protected] mysql]mysql_secure_installation #初始化设置
Linux manual installation configuration MySQL