LNMP of MySQL binary installation

Usually an enterprise environment MySQL installation using two methods

1, MySQL binary packages mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz installation

2, MySQL Source Package installed mysql-5.6.33.tar.gz

Difference:
binary packages easy to install not need to compile, directly extract can be used. However, binary packages than large source package. Here are some methods to install MySQL binary installation package. (A bad place to write exhibitions)

1, the user add mysql
useradd mysql -s / sbin / nologin -M

Parameters: -s / sbin / nologin represent prohibit the user logs on,

-M do not create home directories.

2. Create a directory mkdir / application
explanation: MySQL binary installation packages installed by default in / usr / local, the directory can not be created, this is just a personal habit. Accustomed to the operation and maintenance staff is to take the old road, to avoid a new pit.

3, extract the installation package
the tar--xvf MySQL 5.6.33-Linux-glibc2.5-x86_64.tar.gz
. 4, decompressed file rename
mv mysql-5.6.33-linux-glibc2.5 -x86_64 / application / mysql -5.6.33
5, establishing a soft connection
LN -s /application/mysql-5.6.33 / file application / MySQL
. 6, the main modifications relevant to the MySQL, belonging group
chown -R mysql.mysql / application / mysql /

7, initialize the database
/ file application / MySQL / scripts / = the mysql_install_db --basedir / file application / MySQL --datadir = / file application / MySQL / Data / --user = MySQL
. 8, MySQL copy startup script
cp / application / mysql / support- Files / /etc/init.d/mysqld the mysql.server
. 9, startup script to execute permissions plus
the chmod + X /etc/init.d/mysqld
10, binary packages default installation path / usr / local, so the script the / usr / local alternative to / file application
. 11, start the MySQL
/etc/init.d/mysqld start
starting the MySQL ........................................ [OK]

If you reported the following error:
Starting MySQL.180223 17:46:06 mysqld_safe Directory '/ var / lib / MySQL' File for UNIX socket do not EXISTS.
At The Server quit the without Updating PID File (/ var / lib / MySQL / i [ FAILED] 3fkghffrq11dqZ.pid).

Rename the file /etc/my.cnf

12, check whether MySQL really started
netstat -nplt | grep 3306
tcp 0 0 ::: 3306 ::: * LISTEN 15064 / mysqld

13, if the port is not found MySQL start, link / file application / MySQL / Data / .err log, according to the information given in Debugging
Vim / file application / MySQL / Data /
.err
14, disposed MySQL boot from the start
the chkconfig --add mysqld
the chkconfig oN mysqld
15, set the global variable
vim / etc / profile
in the document the last to join

the PATH = Export / the Application / MySQL / bin: the PATH $
16, log on MySQL, this time without a password can log in and root user
[root @ Jhyeliu the Data] # MySQL
is available for purchase at The MySQL Monitor Commands to End with; or \. . G
Your the MySQL Connection ID. 1 IS
Server Version: the MySQL 5.6.33 Community Community Server (the GPL)
Copyright (C) 2000, 2016, the Oracle and / or ITS Affiliates All Rights Reserved..
the Oracle IS A Registered Trademark of the Oracle Corporation and / or ITS
Affiliates Other names On May BE Trademarks of Their RESPECTIVE.
Owners.
the Type 'Help;'.. or '\ H' for Help the Type '\ C' to Clear the Current INPUT Statement
MySQL>
. 17, if following this happen, reinitialization data.
ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: YES)

1), remove the initialization data directory rm -rf / application / mysql / data

2) to re-initialize

18, MySQL security reinforcement
set a password for the root user

-u the root password mysqladmin 'password'
. 19, clean unwanted library
drop Database Test;
20 is, clean unwanted user
SELECT User, Host from the mysql.user;
+ ------ + --------- - +
| the User | Host |
+ ------ + ----------- +
| root | 127.0.0.1 |
| root | :: 1 |
| | jhyeliu |
| root | jhyeliu |
| | localhost |
| root | localhost |
+ ------ + ----------- +
drop the User "root" @ ":: 1";
Query the OK, 0 rows affected (0.05 sec)

drop user ""@"localhost";
Query OK, 0 rows affected (0.00 sec)

drop user ""@"jhyeliu";
Query OK, 0 rows affected (0.00 sec)

drop user "root"@"jhyeliu";
Query OK, 0 rows affected (0.00 sec)

the User the SELECT, Host from the mysql.user;
+ ------ + ----------- +
| the User | Host |
+ ------ + -------- + ---
| root | 127.0.0.1 |
| root | localhost |
+ ------ + ----------- +
flush privileges;
this point MySQL database even if basically completed.

Guess you like

Origin blog.51cto.com/jhyeliu/2438379