Install MySQL under CentOS7
--Download MySQL
http://mirrors.sohu.com/mysql/MySQL-5.6/
Http://mirrors.sohu.com/mysql/MySQL-5.6/MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar
One. Preparatory work
--File after download
Mysql-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar
--New Folder
Mkdir/home/www/tar
mkdir/home/www/rpm
--Upload files to unzip under RPM package
TAR-XVF Mysql-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar
...
Mysql-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar
mysql-client-5.6.24-1.linux_glibc2.5.x86_64.rpm
mysql-devel-5.6.24-1.linux_glibc2.5.x86_64.rpm
mysql-embedded-5.6.24-1.linux_glibc2.5.x86_64.rpm
mysql-server-5.6.24-1.linux_glibc2.5.x86_64.rpm
mysql-shared-5.6.24-1.linux_glibc2.5.x86_64.rpm
mysql-shared-compat-5.6.24-1.linux_glibc2.5.x86_64.rpm
mysql-test-5.6.24-1.linux_glibc2.5.x86_64.rpm
--Move the tar file to/home/www/tar
MV Mysql-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar/home/www/tar
Second, start the installation
--Start the installation (where V indicates detailed installation information, h indicates that the installation progress is displayed in #)
RPM-IVH mysql-*
--see that the following information has been installed successfully
A RANDOM PASSWORD have BEEN SET for the MySQL root USER!
You'll find that password in '/root/.mysql_secret '.
...
...
New Default Config file was created as/usr/my.cnf and
Would be used by default by the server when you start it.
You could edit this file to the Change server settings
Note: The latest version of MySQL will randomly generate a root user's password, placed in the/root/.mysql_secret file
--View port (default 3306)
[Email protected] init.d]# Netstat-nat
Active Internet connections (servers and established)
Proto recv-q send-q Local address Foreign address state
TCP 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN
TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
TCP 0 0 192.168.1.110:22 192.168.1.119:50608 established
TCP6 0 0::: 3306:::* LISTEN
TCP6 0 0::: $:::* LISTEN
Three, installation position
When installing with RPM, the sub-directories under MySQL are scattered and placed in the following directories:
/etc/logrotate.d/mysql
/etc/rc.d/init.d/mysql MySQL startup configuration script, where only one executable file called MySQL is related to MySQL
/var/lib/mysql Database storage directory in MySQL
/var/lock/subsys/mysql
/usr/lib/mysql//This folder is the MySQL link library
/usr/include/mysql MySQL header file
/usr/share/mysql MySQL installation directory
/usr/bin There are multiple executable programs for MySQL, such as MySQL, Mysql_config_editor, Mysqlcheck, mysqladmin, etc.
Iv. MySQL Stop and restart
/etc/rc.d/init.d/mysql restart
/etc/rc.d/init.d/mysql stop
/etc/rc.d/init.d/mysql start
Five, error troubleshooting
[Email protected] rpm]# Mysql-uroot
--there is a problem
(1) Error: Error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
--Stop Service
/etc/rc.d/init.d/mysql stop
--Safe mode into MySQL
[Email protected] rpm]# mysqld_safe--user=mysql--skip-grant-tables--skip-networking &
[[email protected] rpm]# mysql-u root MySQL
--Change user name
mysql> UPDATE user SET Password=password (' root ') where user= ' root ';
mysql> FLUSH privileges;
Mysql> quit
[Email protected] rpm]# mysql-uroot-p
mysql> show databases;
(2) Error: Error 1820 (HY000): Must SET PASSWORD before executing this statement
--Reset root password
mysql> SET PASSWORD = PASSWORD (' root ');
Query OK, 0 rows Affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |
| Test |
+--------------------+
4 rows in Set (0.00 sec)
(3) Navicat error: Host ' 192.168.1.* ' isn't allowed to connect to this MySQL server
Reason: MySQL does not allow external links in the user table
--Temporarily add ports to the firewall
Firewall-cmd--permanent--zone=public--add-port=3306/tcp
Systemctl Restart Firewalld.service
--Change Host
[Email protected] rpm]# mysql-uroot-p
mysql> use MySQL
Mysql> Select Host, user from user;
+-----------------------+------+
| Host | user |
+-----------------------+------+
| 127.0.0.1 | Root |
| :: 1 | Root |
| localhost | Root |
| Localhost.localdomain | Root |
+-----------------------+------+
4 rows in Set (0.00 sec)
--change localhost to%
mysql> Update user Set host = '% ' where host= ' localhost ';
Query OK, 1 row Affected (0.00 sec)
Rows matched:1 changed:1 warnings:0
Mysql> Select Host, user from user;
+-----------------------+------+
| Host | user |
+-----------------------+------+
| % | Root |
| 127.0.0.1 | Root |
| :: 1 | Root |
| Localhost.localdomain | Root |
+-----------------------+------+
4 rows in Set (0.00 sec)
--Restart MySQL service
/etc/rc.d/init.d/mysql restart
MySQL is now ready for normal use!
Six, boot start
Use the command: Sbin/chkconfig--list to view Startup items
Using the command: Sbin/chkconfig--add MySQL, add MySQL to the boot entry:
Use the command: Sbin/chkconfig--del MySQL to remove MySQL from the boot entry:
CentOS7 under MySQL Installation