System Convention
- Download directory of installation files / opt/software
- Mysql directory installation location: usr/local/mysql
- Database save location / data/mysql
- Log saving location: data/logs/mysql
Dependency package required for MySql installation
Before installing mysql, you'd better install the dependency package required by MySQL first, or there will be many error messages later, and then you have to return to install the dependency package of MySQL. The installation command is as follows:
[root@hadoop01 ~]# yum install ncurses-devel libaio-devel -y
[root@hadoop01 ~]# rpm -qa ncurses-devel libaio-devel
ncurses-devel-5.7-4.20090207.el6.x86_64
libaio-devel-0.3.107-10.el6.x86_64
Tip: after installation, use RPM - QA ncurses devel libaio devel command to check. If two lines of the above information appear, the installation is successful.
mysql installation process
- Download mysql
In official website: http://dev.mysql.com/downloads/mysql/ , select the following version of mysql to download:
- Extract the package to the destination directory
- decompression [root@hadoop01 soft]$ tar zxvf mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz -C /usr/local/ - Modify file name mv mysql-5.7.13-linux-glibc2.5-x86_64 mysql
- Create data warehouse catalog
[root@hadoop01 mysql]$ mkdir -p /data/mysql/
- Create user groups and users of mysql, and set user groups and users on mysql directory
[root@hadoop01 mysql]$ useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql #Create a new msyql user and disable mysql users from logging in to the shell
[root@hadoop01 mysql]# chown -R mysql . # Change directory owner to mysql
[root@hadoop01 mysql]# chgrp -R mysql .
- Initialize mysql
[root@hadoop01 mysql]#bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql # Note the temporary password generated by the record here,You can also view it through the following command:
[root@hadoop01 mysql]# cat /root/.mysql_secret
- Modify mysql configuration file
[root@hadoop01 support-files]# cp my-default.cnf /etc/my.cnf
[root@hadoop01 support-files]#cp mysql.server /etc/init.d/mysql
[root@hadoop01 mysql]# vim /etc/init.d/mysql
basedir=/usr/local/mysql
datadir=/data/mysql
- Configure my.cnf and modify the following
[root@hadoop01 mysql]# vim /etc/my.cnf
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
# General configuration options
basedir = /usr/local/mysql
datadir = /data/mysql
tmpdir = /tmp
log_error = /data/logs/mysql/error.log
port = 3306
socket = /var/lib/mysql/mysql.sock
character-set-server=utf8
lower_case_table_names=1
#The following are optional options. Do you want to use them or not? In case of startup errors, please comment out all of them and keep the most basic configuration options. Then try to add some configuration items and start it. Check whether the configuration items are wrong
back_log = 300
max_connections = 3000
max_connect_errors = 50
table_open_cache = 4096
max_allowed_packet = 32M
#binlog_cache_size = 4M
max_heap_table_size = 128M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size = 16
query_cache_size = 128M
query_cache_limit = 4M
ft_min_word_len = 8
thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
#log-bin=mysql-bin
long_query_time = 6
server_id=1
innodb_buffer_pool_size = 1G
innodb_thread_concurrency = 16
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = on
[mysqldump]
quick
socket = /var/lib/mysql/mysql.sock
max_allowed_packet = 32M
[mysql]
no-auto-rehash
safe-updates
socket = /var/lib/mysql/mysql.sock
[myisamchk]
key_buffer = 16M
sort_buffer_size = 16M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
- mysql start
1,Start mode 1
[root@hadoop01 mysql]# bin/mysqld_safe --user=mysql # There is an error in the startup process, generally due to the permission problem. It is OK to use chmod to empower
2, Start mode 2
[root@hadoop01 support-files]# ./mysql.server start # After joining the system service, you can start it through service mysql start to view the system service:
[hadoop@hadoop01 support-files]$ chkconfig --list
- Landing mysql
1,Using initialization password:5ul#H6dmcwX starts to log in to mysql:
[root@hadoop01 bin]# ./mysql -uroot -p
2,modify mysql Of root Password, the new password here is'123456'
mysql> set password=password('123456');
3,Set up remote login mysql. stay Linux For security, it is not allowed by default mysql Machine access outside the local machine mysql Database service, so it needs to be re authorized root. Easy remote access.
mysql> use mysql;
Database changed
mysql> select Host,User from user;
+-----------+-----------+
| Host | User |
+-----------+-----------+
| % | root |
| localhost | mysql.sys |
| localhost | root |
+-----------+-----------+
3 rows in set (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
4,Unnecessary steps. If you can't connect remotely, it's probably a firewall problem. Close it and try:
[root@hadoop01 mysql]# service iptables stop
- Add system path
[root@hadoop01 mysql]# vim /etc/profile
//Add to:
export PATH=/usr/local/mysql/bin:$PATH
[root@hadoop01 mysql]# source /etc/profile # Effective after modification
- Configure mysql startup
[root@hadoop01 mysql]#chmod 755 /etc/init.d/mysql
[root@hadoop01 mysql]#chkconfig --add mysql
[root@hadoop01 mysql]#chkconfig --level 345 mysql on
Common installation exceptions
-
InnoDB: The error means mysqld does not have the access rights to the directory
- Solving chmod-r 777 weighting
-
'./ibdata1' could not be found in the doublewrite buffer
-
Can't connect to local MySQL server through socket '/usr/local/mysql/mysql.sock'
Installation reference
http://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
For source code installation, please refer to [CentOS7 installation MYSQL5.7.7]
Refer to: http://blog.csdn.net/jssg_tzw/article/details/68944693
For the installation of yum mode, please refer to: http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html
lib package installation reference: http://www.bkjia.com/Mysql/1136522.html And http://blog.51cto.com/lavasoft/1733207
- my.cnf of mysql: http://www.cnblogs.com/EasonJim/p/7158466.html