Linux archive installed Mysql
1. Select mysql installation directory (mysql installed in / usr / local / mysql directory)
mkdir mysql
2. Local mysql download archive
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
3. Delete the mysql linux (not recommended for use deleted)
1) Use the following command to view the current situation install mysql, mysql look for before or not incorporating
rpm -qa|grep -i mysql
2) stop the mysql service, delete the previously installed mysql
删除命令:rpm -e –nodeps 包名
3) Find a directory before the old version of mysql, mysql and delete old versions of files and libraries
find / -name mysql
rm -rf ../mysql
Note: /etc/my.cnf not deleted after uninstalling, you need to manually delete
rm -rf /etc/my.cnf
4) Find again the machine is installed mysql
rpm -qa|grep -i mysql
4. The local archive mysql uploaded to the server / home directory
1.cd /home
2.rz(上传文件命令)
The extracting archive mysql
tar -zxvf (mysql压缩包名称) -C /usr/local/mysql
6. Create a data directory
mkdir /usr/local/mysql/data
7. Create mysql user and modify permissions
groupadd mysql
chown -R mysql.mysql /usr/local/mysql/
8. initialization data
[root@localhost mysql] ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
9. Copy the mysql /support-files/mysql.server/ to /etc/init.d/mysqld
cp -a ./support-files/mysql.server /etc/init.d/mysqld
10. Start mysql
service mysqld start
11. Check whether a successful start mysql
service mysqld status
MySQL running (47434) 表示启动成功
Question: linux, mysql in the case of normal operation, enter the mysql prompt:
mysql command not found
Met -bash: mysql: command not found the case do not worry, this is because of the lack mysql cause under / usr / local / bin directory, just click method for establishing soft links that can be resolved:
the mysql installation directory, such as / usr / local / mysql / bin / mysql , mapped to / usr / local / bin directory:
cd /usr/local/bin
ln -fs /usr/local/mysql/bin/mysql mysql
Problem: After using the delete, delete the file linux /etc/my.cof cause "ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: YES)" error
Solution: Create my local .cnf file copy the following code to the my.cnf file and incoming server's / etc / directory
[client]
#password= 123456
port= 3306
socket= /tmp/mysql.sock
default-character-set=utf8
#Here follows entries for some specific programs
#The MySQL server
[mysqld]
skip-name-resolve
skip-grant-tables
port= 3306
socket= /tmp/mysql.sock
datadir= /usr/local/mysql/data
character-set-server=utf8
collation-server=utf8_general_ci
skip-external-locking
key_buffer_size = 8M
max_allowed_packet = 16M
table_open_cache = 2048
#table_definition_cache= 256
sort_buffer_size = 8M
#log-bin=/home/mysql/data/mysql-bin
net_buffer_length = 32K
read_buffer_size = 2M
read_rnd_buffer_size = 16M
myisam_sort_buffer_size = 4M
binlog_format=mixed
server-id = 1
event_scheduler=ON
back_log = 50
wait_timeout = 1800
interactive-timeout = 1800
#最大连接数
max_connections = 1000
max_connect_errors = 10
binlog_cache_size = 1M
max_heap_table_size = 96M
join_buffer_size = 8M
thread_cache_size = 8
#thread_concurrency = 8
query_cache_size = 64M
query_cache_limit = 2M
memlock
default-storage-engine = INNODB
thread_stack = 192K
tmp_table_size = 96M
log_short_format
key_buffer_size = 16M
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 32M
binlog-do-db=chinaventure
expire_logs_days=5
log_bin_trust_function_creators = 1
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
expire_logs_days=5
log_bin_trust_function_creators = 1
#innodb_data_file_path=ibdata1:128M;ibdata2:10M:autoextend
innodb_file_per_table=128M
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
#Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
skip-name-resolve
**注意:如果mysql解压目录不在/usr/local/mysql,则需要修改mysql.server文件的basedir和datadir等路径**