By installing the package name, we can get to a lot of information, if you download the installation package is not, someone else for you, how to tell this installation package is suitable to you to use it?
We turn to interpret it, following the installation package name
mysql-5.7.19-linux-glibc2.12-x86_64.tar
- This is version 5.7.19 installation package database
- Suitable for installation in Linux operating system platform
- Glibc2.12 or later operating system kernel
- X86-64-bit operating system is
Installing MySQL
In fact, not many steps, compared to Oracle simply pediatrics, mainly in the following steps:
1. Download the installation package (completed)
How to download MySQL installation package
2. Extract the installation package
[root@dd01 ~]# tar -xvf /tmp/mysql-5.7.14-linux-glibc2.12-x86_64.tar
Users and groups on the OS 3. Configure
MySQL users do not need to configure bash, because the user does not log in to use the little, short, just need the ordinary user's identity and authority:
[root@dd01 ~]# groupadd mysql
[root@dd01 ~]# useradd -g mysql -s /bin/false mysql
[root@dd01 ~]# passwd mysql
4. Deploy MySQL software
We will extract the good directory, move to the system directory, the software is deployed, the equivalent of a green version of the software
[root@dd01 ~]# mv /tmp/mysql-5.7.19-linux-glibc2.12-x86_64 /usr/local/mysql
[root@dd01 ~]# chown -R mysql:mysql /usr/local/mysql
The parameter configuration file MySQL
We configure the most simple, MySQL configuration file my.cnf content
[root@dd01 ~]# vi /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql/data
server_id=1
port=3306
basedir: points to the location where the MySQL software.
datadir: data file location.
server_id: there is no mandatory requirement, as long as the numbers can be.
port: port number. MySQL default port number is 3306, some companies for data security, abandoned all default port numbers. For example, write 3307.
6. Configure MySQL directory
Find plenty of space partitioning, MySQL database as a data storage location
[root@dd01 ~]# mkdir -p /data/mysql
[root@dd01 ~]# cd /data/mysql
[root@dd01 ~]# mkdir run tmp logs binlogs data
[root@dd01 ~]# chown -R mysql:mysql /data
7. yuan MySQL database initialization
Enter the location where the MySQL software, go to the bin directory, execute initialization commands, see the root @ localhost as long as the position of the last few lines: ZFo#uySxE8x?
the words, indicating successful initialization.
Red part of acquaintance disorder, temporary super password, everyone is different, but the need to temporarily put aside, for a moment will be used
[root@dd01 bin]# cd /usr/local/mysql/bin
[root@dd01 bin]# ./mysqld --initialize --user=mysql
....
2017-12-07T22:47:04.667289Z 1 [Note] A temporary password is generated for root@localhost: ZFo#uySxE8x?
8. Add MySQL startup items
Add the mysql command to the system command library:
[root@dd01 bin]# ln -s /usr/local/mysql/bin/mysql /usr/bin
Linux mysql replication services are added to the system:
[root@dd01 bin]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
Turn off the firewall
[root@dd01 bin]# service iptables stop -- 临时关闭
[root@dd01 bin]# chkconfig iptables off -- 永久关闭
9. Start the database
Start the database service
[root@dd01 bin]# service mysqld start
Verify database starts Method 1: View OS processes
after the correct start MySQL will run up the two processes,
[root@dd01 ~]# ps -ef | grep mysql
root 13642 1 0 15:48 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/u01/mysql/data --pid-file=/u01/mysql/data/LK01.pid
mysql 13781 13642 0 15:48 ? 00:01:13 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/u01/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=LK01.err --pid-file=/u01/mysql/data/LK01.pid --port=3306
root 15212 14762 0 21:47 pts/2 00:00:00 mysql -h 192.168.56.88 -utom -px xxx
root 15932 15769 0 23:43 pts/6 00:00:00 grep mysql
Verify database starts Method 2: Log database
first landing MySQL database, the need to use a temporary password just oh
[root@dd01 bin]# mysql -uroot -p'ZFo#uySxE8x?'
mysql>
But this is too difficult to remember a password, and after using this temporary password can not do anything, we need to change the password the first time
mysql> set password=password('mysql');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Then we use the new password to log in, you can.
But the second landing we want a more secure way to login, then do not enter a password after -p, or will leave the key in the password history, this is very unsafe, so we can use the following method
[root@dd01 bin]# mysql -uroot -p
Enter password: <--- 我们在此处输入密码是看不到的,盲输完密码后回车!就可以登陆了
mysql>
Set at startup MySQL
The software is set up mysql boot from Kai
[root@dd01 init.d]# chkconfig --add mysqld
[root@dd01 init.d]# chkconfig --list | grep mysql
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off