1 overview
First look at MySQL:
http://ftp.plusline.de/mysql/Downloads/
There are various versions of MySQL here
Operating system: CentOS release 6.8 (Final)
Database version: mysql-5.6.31
2 planning
MySQL Program home directory |
/mysql |
Genus: MySQL owner: root |
MySQL Data Catalog |
/data |
Genus: MySQL owner: MySQL |
MySQL configuration file |
/mysql |
Genus: MySQL owner: root |
MySQL Port number |
3306 |
|
Sock |
/mysql/mysql.sock |
Genus: MySQL owner: root |
|
|
|
|
|
|
3 Installation 3.1 Preparation before installation
First make sure the software is installed:
Cmake,make,gcc,perl,
Yum Install Cmake,make,gcc,perl-y
3.2 Installing 3.2.1 Decompression software
TAR-ZXVF mysql-5.6.31.tar.gz
3.2.2 Compiling and installing
Go to MySQL Directory
CD mysql-5.6.31
Create a Directory
mkdir Bootstarp
Configuring parameters for compiled configurations
CMake. -dcmake_install_prefix =/mysql the installation base directory.
-dmysql_datadir =/data The location of the MySQL data directory.
-dsysconfdir=/mysql The default my.cnf option file directory.
-dwith_innobase_storage_engine=1
-dwith_archive_storage_engine=1
-dwith_blackhole_storage_engine=1
-dwith_perfschema_storage_engine=1
-dmysql_tcp_port=3306 the PORT number on which the server listens for TCP/IP connections. The default is 3306.
-dmysql_unix_addr=/mysql/mysql.sock
3.3 Make and make install
Make
Make install
MySQL installation is complete at this point
4 post-Installation work 4.1 Initializing data Directory
CD MySQL
CP./SUPPORT-FILES/MY-DEFAULT.CNF MY.CNF
Then edit MySQL to add the following selections:
Basedir =/mysql
DataDir =/data
Port = 3306
Socket =/mysql/mysql.scok
Change permissions for the current directory
Chown-r MySQL.
Chgrp-r MySQL.
Initializing the Data directory
scripts/mysql_install_db--user=mysql
4.2 Last change to install directory permissions
You can also not change
4.3 Starting the MySQL server
Shell> Bin/mysqld_safe--user=mysql &
4.4 Testing the MySQL server
Shell> bin/mysqladmin Version
Shell> bin/mysqladmin variables
4.5 Initializing MySQL Account
After the MySQL installation, there are root users and anonymous users, the root user does not have a password, the anonymous user indicates that anyone can connect to MySQL, which is safe.
The statements to view these users are as follows:
Mysql> SELECT User, Host, Password from Mysql.user;
So we need to set a password for the root user, set the password for the anonymous user, or delete the anonymous user.
4.5.1 setting a password for the root user
Method one.
Use the SET command to set a password for each user on top.
SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' 111111 ');
Set password for ' root ' @ ' Mysql.localdomain ' =password (' 111111 ');
Set password for ' root ' @ ' 127.0.0.1 ' =password (' 111111 ');
SET PASSWORD for ' root ':: 1 ' = PASSWORD (' 111111 ');
Method Two:
We can do it with a single command.
UPDATE mysql.user SET Password = Password (' new_password ') WHERE user = ' root ';
FLUSH privileges;
Flush privileges is to tell the server to reread the authorization form, otherwise the user name password set will only take effect after the MySQL server restarts.
Method Three.
We can also use mysqladmin to change the password for the root user.
mysqladmin-u root Password "New_password"
Mysqladmin-u root-h host_name Password "New_password"
4.5.2 setting a password for anonymous users
Method one.
Set password for ' @ ' localhost ' =password (' 111111 ');
Set password for ' @ ' Mysql.localdomain ' =password (' 111111 ');
Method Two.
UPDATE mysql.user SET Password = Password (' new_password ') WHERE user = ';
FLUSH privileges;
4.5.3 Deleting anonymous users
DROP USER ' @ ' localhost ';
DROP USER ' @ ' mysql.localdomain ';
5 Test security issues
By default, the Mysql.db table contains rows that define whether any user can access the test database, or a database that begins with Test_, which is safe and should be removed.
DELETE from mysql.db WHERE db like ' test% ';
DELETE from mysql.db WHERE db like ' test% ';
or delete the test database without establishing a database that starts with test.
Source code compilation Install MySQL