Environment:
[Email protected] ~]# cat/etc/redhat-release
CentOS Release 6.8 (Final)
[Email protected] ~]# uname-r
2.6.32-642.el6.x86_64
To start the installation configuration:
[Email protected] ~]# cd/usr/local/src/
[Email protected] src]# wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz
[Email protected] src]# ll-h
Total 178M
-rw-r--r--1 root root 178M Apr 16:27 mysql-5.5.55-linux2.6-x86_64.tar.gz
[[Email protected] src]# tar zxf mysql-5.5.55-linux2.6-x86_64.tar.gz-c/usr/local/# Unzip
[Email protected] src]# CD.
[[Email protected] local]# MV mysql-5.5.55-linux2.6-x86_64/mysql-5.5.55 # Renaming
[[email protected] local]# ln-s mysql-5.5.55 MySQL # make a soft connection
[[email protected] local]# useradd mysql-s/sbin/nologin-m # Build system users
[Email protected] local]# mysql/scripts/mysql_install_db--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/ data/--user=mysql # Initializing database
[[email protected] local]# chown-r mysql:mysql mysql-5.5.55 # authorization to the directory
[[email protected] local]# VI/ETC/MY.CNF # Create configuration file, test with
[client]port=3306socket= /usr/local/mysql/mysql.sock[mysqld]user = mysqldatadir = /usr/local/mysql/data/character-set-server = utf8skip-character-set-client-handshakeinit-connect = ' Set names utf8 ' open_files_limit= 1024back_log = 600max_connections = 800max_connect_errors = 3000table_cache = 614external-locking = FALSEmax_allowed_packet =8Msort_buffer_size = 1mjoin_buffer_size = 1mthread_cache_size = 100thread_concurrency = 2query_cache_ size = 2mquery_cache_limit = 1mquery_cache_min_res_unit = 2kthread_stack = 192ktmp_table_size = 2mmax_heap_table_size = 2mlog-bin = /usr/local/mysql/ data/mysql-binbinlog_cache_size = 1mmax_binlog_cache_size = 1mmax_binlog_size = 2mexpire_logs_days = 7key_buffer_size = 16mRead_buffer_size = 1mread_rnd_buffer_size = 1mbulk_insert_buffer_size = 1mlower_ case_table_names = 1skip-name-resolveslave-skip-errors = 1032,1062replicate-ignore-db= mysqlserver-id = 1innodb_additional_mem_pool_size = 4minnodb_buffer_pool_size = 16minnodb_file_io_threads = 4innodb_thread_concurrency = 8innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 2minnodb_log_file_size = 4minnodb_log_files_in_ Group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120innodb_ file_per_table = 0[mysqldump]quickmax_allowed_packet = 2m[mysqld_safe]log-error=/var/log/ Mysqld.logpid-file=/var/run/mysqld/mysqld.pid
[[email protected] local]# CP mysql/bin/* sbin/# Copy execution command to Sbin
[[email protected] local]# CP mysql/support-files/mysql.server/etc/init.d/mysqld # Generate startup script
[[email protected] local]#/etc/init.d/mysqld start # Direct Start service
Starting MySQL ... success!
[[email protected] ~]# Netstat-lntup # View Services
Active Internet connections (only servers)
Proto recv-q send-q Local address Foreign address State Pid/program Name
TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 7853/mysqld
[Email protected] ~]# lsof-i:3306
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
mysqld 7853 MySQL 12u IPv4 24118 0t0 TCP *:mysql (LISTEN)
[[email protected] local]# mysqladmin-u root password # give the root password, the default secret login
Enter Password:
[[email protected] local]# mysql-uroot-p # Interactive Password login
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 3
Server Version:5.5.55-log MySQL Community Server (GPL)
Copyright (c), Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |
| Test |
+--------------------+
4 rows in Set (0.13 sec)
mysql> drop database test; # Remove the test library
Query OK, 0 rows Affected (0.00 sec)
Mysql> select User,host from Mysql.user;
+------+-----------+
| user | Host |
+------+-----------+
| Root | 127.0.0.1 |
| Root | :: 1 |
| | localhost |
| Root | localhost |
| | sql-m |
| Root | sql-m |
+------+-----------+
6 rows in Set (0.11 sec)
mysql> drop user [email protected] ':: 1 '; # Delete a useless user
Query OK, 0 rows affected (0.14 sec)
mysql> drop user ' @localhost;
Query OK, 0 rows Affected (0.00 sec)
mysql> drop user ' @ ' sql-m ';
Query OK, 0 rows Affected (0.00 sec)
mysql> drop user [email protected] ' sql-m ';
Query OK, 0 rows affected (0.03 sec)
Mysql> select User,host from Mysql.user;
+------+-----------+
| user | Host |
+------+-----------+
| Root | 127.0.0.1 |
| Root | localhost |
+------+-----------+
2 rows in Set (0.00 sec)
mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)
Mysql> quit
[[email protected] local]# mysqladmin-uroot-p123 Password # change password
New Password:
Confirm New Password:
Test forgot root password re-retrieved:
[[email protected] ~]#/etc/init.d/mysqld Stop # First stop the service
Shutting down MySQL. success!
[[email protected] ~]# mysqld_safe--skip-grant-tables & # Ignore authorization table mode start service
[1] 3685
170422 17:37:34 mysqld_safe Logging to '/var/log/mysqld.log '.
170422 17:37:34 Mysqld_safe starting mysqld daemon with databases From/usr/local/mysql/data
[Email protected] ~]# 170422 17:37:39 mysqld_safe mysqld from PID File/var/run/mysqld/mysqld.pid ended
[1]+ done Mysqld_safe--skip-grant-tables
Strange to have failed! Check the log first ...
[Email protected] ~]# Tail/var/log/mysqld.log
170422 17:39:41 innodb:waiting for the background threads to start
170422 17:39:42 innodb:5.5.55 started; Log sequence Number 1595668
170422 17:39:42 [Note] Recovering after a crash using/usr/local/mysql/data/mysql-bin
170422 17:39:42 [Note] starting crash recovery ...
170422 17:39:42 [Note] Crash recovery finished.
170422 17:39:42 [Note] Server hostname (bind-address): ' 0.0.0.0 '; port:3306
170422 17:39:42 [Note]-' 0.0.0.0 ' resolves to ' 0.0.0.0 ';
170422 17:39:42 [Note] Server socket created on IP: ' 0.0.0.0 '.
170422 17:39:42 [ERROR]/usr/local/sbin/mysqld:can ' t create/write to file '/var/run/mysqld/mysqld.pid ' (errcode:2)
170422 17:39:42 [ERROR] Can ' t start server:can ' t create PID file:no such file or directory
As you can see, you can't create a PID file, which is definitely not a privilege.
/var/run/mysqld This path is a configuration file:
[Email protected] ~]# tail-3/etc/my.cnf
[Mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid
It's a little strange here, when you start a service with/etc/init.d/mysqld, it doesn't read the PID path configured in the configuration file, and starting the service with Mysqld_safe--skip-grant-tables & ignore authorization table will read the configuration file PID path.
Don't want to move/var/log/This directory permissions, change the configuration file
[Email protected] ~]# VIM/ETC/MY.CNF
[Mysqld_safe]log-error=/var/log/mysqld.logpid-file=/usr/local/mysql/mysqld.pid
[[email protected] ~]#/usr/local/mysql/bin/mysqld_safe--skip-grant-tables & # Execute again
[1] 7109
170422 17:54:17 mysqld_safe Logging to '/var/log/mysqld.log '.
170422 17:54:17 Mysqld_safe starting mysqld daemon with databases From/usr/local/mysql/data
[Email protected] ~]# # This time it's OK
[[email protected] ~]# MySQL # password-free login
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server Version:5.5.55-log MySQL Community Server (GPL)
Copyright (c), Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql>
mysql> Update Mysql.user set Password=password (' 123 ') where user= ' root ' and host= ' localhost '; # Change Password
Query OK, 1 row Affected (0.00 sec)
Rows matched:1 changed:1 warnings:0
mysql> flush Privileges;
Query OK, 0 rows affected (0.19 sec)
Suddenly think of Mysqld_safe this command so powerful, look at its permissions:
[Email protected] ~]# Ll/usr/local/sbin/mysqld_safe
-rwxr-xr-x 1 root root 27100 Apr 16:39/usr/local/sbin/mysqld_safe
Scare a jump There is no, incredibly what people can execute, too dangerous!
Get rid of it now, two places to get rid of:
[Email protected] ~]# chmod 700/usr/local/sbin/mysqld_safe
[Email protected] ~]# chmod 700/usr/local/mysql/bin/mysqld_safe
[Email protected] ~]# Ll/usr/local/sbin/mysqld_safe
-rwx------1 root root 27100 Apr 16:39/usr/local/sbin/mysqld_safe
[Email protected] ~]# Ll/usr/local/mysql/bin/mysqld_safe
-rwx------1 mysql mysql 27100 Mar 13:14/usr/local/mysql/bin/mysqld_safe
The above binary package is simple to install and complete.
This article came from "never thought to give up!" "Blog, be sure to keep this provenance http://yuyicong.blog.51cto.com/11274530/1918544
MySQL-5.5 Binary Package Installation