Original CentOS-7 under Installation MySQL5.6.22
An installation environment
(1) CentOS version: CentOS-7
To view the method:
[[Email protected] Desktop]# cat/etc/redhat-release
CentOS Linux release 7.0.1406 (Core)
: http://www.centos.org/
(2) MySQL version: MySQL-5.6.22
: Https://edelivery.oracle.com/EPD/Search/handle_go
or Http://pan.baidu.com/s/1dDu6n9R.
Name: MySQL Database 5.6.22 RPM for Oracle Linux/rhel 7 x86 (64bit)
Two mounting options
After searching the internet, there are three ways of installing MySQL under Linux:
1 Download the installation online via the Yum command
2 Download offline RPM installation package installation
3 Download Source Compilation installation
Mode 1 is not intended to be used, because most of our project servers are not directly on the Internet, there are many tutorials on online installation, and mode 3 is not necessary for anyone applying MySQL to superfluous.
Three installation steps
1. Unzip the downloaded Zip package and you will find the following RPM packages:
mysql-client-advanced-5.6.22-1.el7.x86_64.rpm
mysql-devel-advanced-5.6.22-1.el7.x86_64.rpm
mysql-embedded-advanced-5.6.22-1.el7.x86_64.rpm
mysql-server-advanced-5.6.22-1.el7.x86_64.rpm
mysql-shared-advanced-5.6.22-1.el7.x86_64.rpm
mysql-shared-compat-advanced-5.6.22-1.el7.x86_64.rpm
mysql-test-advanced-5.6.22-1.el7.x86_64.rpm
2. Uninstalling MARIADB
If you click on the RPM package installation you will get an error message. Because the CentOS default database is no longer MySQL, but mariadb, why?
MARIADB database management System is a branch of MySQL, mainly by the open source community in the maintenance, the use of GPL license. One of the reasons for developing this branch is that after Oracle acquired MySQL, there is a potential risk of shutting MySQL out of the source, so the community uses a branching approach to avoid this risk. MARIADB is designed to be fully compatible with MySQL, including APIs and command lines, making it easy to be a replacement for MySQL.
To view the currently installed MARIADB package:
[Email protected] Desktop]# Rpm-qa | grep mariadb
Remove them all forcibly:
[Email protected] Desktop]# rpm-e--nodeps mariadb-libs-5.5.35-3.el7.x86_64
[Email protected] Desktop]# rpm-e--nodeps mariadb-5.5.35-3.el7.x86_64
[Email protected] Desktop]# rpm-e--nodeps mariadb-server-5.5.35-3.el7.x86_64
3. Install MySQL
Double-click the following three packages for automatic installation:
mysql-client-advanced-5.6.22-1.el7.x86_64.rpm
mysql-devel-advanced-5.6.22-1.el7.x86_64.rpm
mysql-server-advanced-5.6.22-1.el7.x86_64.rpm
Hint: In fact, the second package devel I do not know what to do, do not know whether it is necessary (Internet search should not be necessary), no test whether it must have been point to install, do not want to take the time to test whether it must be, have tested friends trouble message to inform.
4. Start MySQL
[[email protected] desktop] #service mysql start
Get error:error! The server quit without updating PID file
We are here mainly because:SELinux, if it is a CentOS system, the default is to turn on SELinux. The workaround is to close it, open the/etc/selinux/config, change the selinux=enforcing to selinux=disabled, and then save the restart machine.
And then start MySQL again, there's no problem:
[[email protected] desktop] #service mysql start
To view MySQL running status:
[[Email protected] Desktop]# service MySQL status
success! MySQL Running (2377)
5. Default root user login MySQL
[Email protected] Desktop]# mysql-u root-p
Enter Password:
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)
I found something wrong, and then I looked it up on the Internet. Use the following command to modify the root initialization password:
[[Email protected] Desktop]#/usr/bin/mysqladmin-u root password ' passok '
/usr/bin/mysqladmin:connect to server at ' localhost ' failed
Error: ' Accessdenied for user ' root ' @ ' localhost ' (using Password:no) '
Find MySQL database default root user still can't set password to log in, need to do a bit of action:
Resetting the root user password and authentication in MySQL
Or not, and then find a way to reset the root user password and authentication in MySQL on the Internet:
(1) Stop MySQL Service
[[Email protected] Desktop]# service MySQL stop
Shutting down MySQL. success!
(2) Input bypass password Authentication command
[Email protected] Desktop]# mysqld_safe--user=mysql--skip-grant-tables--skip-networking &
[1] 5807
150117 22:23:31 mysqld_safe Logging to '/var/lib/mysql/bogon.err '.
150117 22:23:31 Mysqld_safe starting Mysqlddaemon with databases From/var/lib/mysql
(3) Enter login user command
[[Email protected] Desktop]# mysql-u root MySQL
Reading table information for completion oftable and column names
Can turn off this feature to get Aquicker startup with-a
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server version:5.6.22-enterprise-commercial-advanced MySQL Enterprise Server-advancededition (commercial)
Copyright (c) and/or, Oracle, Itsaffiliates. All rights reserved.
Oracle is a registered trademark of oraclecorporation and/or its
Affiliates. Other names trademarksof their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' toclear the current input statement.
(4) Enter the change root password SQL statement
Mysql> UPDATEuser SET password=password (' Passok ') where user= ' root ';
Query OK, 4 rows affected (0.04 sec)
Rows Matched:4 Changed:4 warnings:0
(5) Input Data Refresh command
Mysql> flushprivileges;
Query OK, 0 rows Affected (0.00 sec)
(6) Exit
Mysql> quit
Bye
(7) Start MySQL
[[Email protected] Desktop]# service MySQL start
Starting MySQL success!
Log in to MySQL and view all databases:
[Email protected] Desktop]# mysql-u root-p
mysql> show databases;
ERROR 1820 (HY000): Must SET PASSWORD before executing this statement
There is still a mistake ah, prompted to set the password again:
mysql> SetPassword = PASSWORD (' Passok ');
Query OK, 0 rows Affected (0.00 sec)
To display the database:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |
| Test |
+--------------------+
4 rows in Set (0.00 sec)
Enter the database to create the table, display the table:
mysql> use test;
Database changed
Mysql> Show tables;
Empty Set (0.02 sec)
Mysql>create table TestTable (name char () not null,passwd char (n) not null);
Query OK, 0 rows affected (0.87 sec)
Mysql> Show tables;
+----------------+
| Tables_in_test |
+----------------+
| TestTable |
+----------------+
1 row in Set (0.00 sec)
Note: The password for my settings is "Passok". Everyone in execution showdatabases receive error 1820 (HY000): You must SET PASSWORD before executing this Statement can also try to log in to MySQL in the following way to execute showdatabases whether there will be no such error, I have no condition test:
Login MySQL Interface: mysql–uroot-p (modified new password)
Example: Mysql-u root-p123456
MySQL installs the following three main directories and their functions:
/var/lib/mysql Database files
/usr/share/mysql commands and configuration files
/usr/bin Mysqladmin, mysqldump and other commands
6. Connect to the remote MySQL Server using workbench on Windows7
(1) Download install Workbench (MySQL Workbench 6.2.4 MSI for Windows x86 (64bit))
(2) Installing MySQL Workbench under Windows requires the following environments:
Microsoft. NET Framework 4 Client profile
Microsoft Visual C + + redistributablepackage (x64)
The first one goes without saying, and the second one is:
http://www.microsoft.com/zh-CN/download/details.aspx?id=40784
(3) When the installation is complete, open and configure the connection:
Found not connected.
Open cmd command line input telnet 192.168.1.108 3306 is also prompted to connect (Bty:windows7 does not have Telnet installed by default, you need to turn on the Telnet client feature by turning Windows features on or off in Control Panel).
If you want to access the MySQL database remotely, you also need:
(1) give the specified user permission to access the MySQL database remotely;
(2) Configure the firewall to release the 3306 port limit;
1 give the specified user permission to access the MySQL database remotely
The Authorization command is:
Grant permission 1, permission 2,... Permission n on the database name. Table name to User name @ user address identified by ' password '
[[Email protected] Desktop]# mysql-uroot-ppassok-e "GRANT all privileges on * * to ' root ' @ '% ' identified by ' Passok ' with GRAN T OPTION; "
Warning:using a password on the CommandLine interface can be insecure.
Execute the grant command as the root user (the-e parameter represents the execution of a SQL command), meaning that all permissions on all tables in all databases are assigned to the root user at all IP addresses. If you just want the root user on top of the 192.168.1.108 machine to access, the command is as follows:
Mysql-uroot-ppassok-e "GRANT all privileges on * * to ' root ' @ ' 192.168.1.108 ' identified by ' Passok ' with GRANT OPTION;"
2 Configuring the firewall to release the 3306 port limit
The CentOS 7.0 version of the firewall, the default is firewall, with the previous version using Iptables is not the same, after my test, as long as firewall is turned on, it is impossible to remotely access the MySQL database.
First, close the firewall:
[[Email protected] Desktop]# systemctl stop Firewalld.service #停止firewall
[Email protected] Desktop]# systemctl disable Firewalld.service #禁止firewall开机启动
CentOS Although the default is not iptables, but it is already installed, and then I follow the online method, for the 3306 port configuration Open rules:
[[Email protected] Desktop]# vi/etc/sysconfig/iptables
# Sample configuration for iptables service
# can edit this manually or Usesystem-config-firewall
# Please don't ask us to add additionalports/services to this default configuration
*filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m State--staterelated,established-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-i lo-j ACCEPT
-arh-firewall-1-input-m State--state new-m tcp-p TCP--dport 3306-j ACCEPT
-A input-p tcp-m state--state new-m tcp--dport 22-j ACCEPT
-A input-j REJECT--reject-withicmp-host-prohibited
-A forward-j REJECT--reject-withicmp-host-prohibited
COMMIT
Then restart the firewall:
[[Email protected] Desktop]# service iptables restart
Then immediately with the MySQL Workbench Test, found that the same is not connected.
Then execute the following command to permanently shut down iptables:
[Email protected] bin]# chkconfig iptables off
Note: The request is being forwarded to "Systemctl disable Iptables.service".
Then immediately with the MySQL Workbench Test, found that the same is not connected.
Re-start the CentOS system and connect successfully
It appears that a restart is required to take effect.
Further testing:
To view the firewall status is off:
[[Email protected] bin]# service firewall status
Redirecting To/bin/systemctl status Firewall.service
Firewall.service
Loaded:not-found (reason:no such file or directory)
Active:inactive (Dead)
Viewing the Iptables status is also off:
[[Email protected] bin]# service iptables status
Redirecting To/bin/systemctl status Iptables.service
Iptables.service-ipv4 Firewall Withiptables
loaded:loaded (/usr/lib/systemd/system/iptables.service; disabled)
Active:inactive (Dead)
Then I start the iptables firewall, or can access, and then put the rules in the/etc/sysconfig/iptables all commented out, still can access, restart or can, do not know why, view the status of Iptables is also in the active state:
[Email protected]]# service iptables status
Redirecting To/bin/systemctl status Iptables.service
Iptables.service-ipv4 Firewall Withiptables
loaded:loaded (/usr/lib/systemd/system/iptables.service; disabled)
Active:active (exited) since day 2015-01-1818:17:07 CST; 20s ago
process:14440 execstop=/usr/libexec/iptables/iptables.init Stop (code=exited, status=0/success)
process:14648 execstart=/usr/libexec/iptables/iptables.init Start (code=exited, status=0/success)
mainpid:14648 (code=exited, status=0/success)
January 18:17:07 bogoniptables.init[14648]: iptables:applying firewall rules: [OK]
January 18:17:07 bogonsystemd[1]: Started IPv4 Firewall with iptables.
It is possible to permanently shut down the iptables firewall anyway, but remember to reboot.
7. Set up MySQL boot from boot
Set Boot start service Select Use the Chkconfig command, you can see that we permanently shut down iptables this command, the format of the command is as follows:
Chkconfig function Description: Check, set the various services of the system.
Syntax: chkconfig [--add][--del][--list][system service] or Chkconfig [--level < rank code >][system service][on/off/reset]
--add Adding services
--del Deleting a service
--list viewing the Start status of each service
I installed MySQL here after the default is the boot-up:
[[Email protected] Desktop]# chkconfig--list MySQL
Note: This output shows only the SysV service and does not contain the native SYSTEMD service. SysV configuration data may be overwritten by native SYSTEMD configuration.
If you would like to list the SYSTEMD service, please do ' systemctl list-unit-files '.
To view services enabled for a specific target, perform
' Systemctl list-dependencies [target] '.
MySQL 0: off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off
If it is not booting up, use the turn on MySQL service auto-on command:
Chkconfig mysqld on
Chkconfig MySQL on
CentOS-7 under Installation MySQL5.6.22