I. Pre-installation inspection
1. when downloading, pay attention to the 32-bit or 64-bit
Linux views the number of commands is uname-a, if there is x86_64, that is 64 bits.
I686 is 32-bit
Linux view version of command cat/etc/system-release
2. Check if MySQL is installed
Rpm-qa | grep MySQL
3. Uninstall the installed MySQL
Rpm-e--nodeps xxxxxx xxxxxx is the name of the above query
4. Attention to Detail:
检查一下系统是否存在 mariadb 数据库,如果有,一定要卸载掉,否则可能与 mysql 产生冲突。
系统安装模式的是最小安装,所以没有这个数据库。
检查是否安装了 mariadb:[[email protected] ~]# rpm -qa | grep mariadb
如果有就使劲卸载干净:
systemctl stop mariadb
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-5.5.52-1.el7.x86_64
rpm -e --nodeps mariadb-server-5.5.52-1.el7.x86_64
rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
5. system Memory Check
Check the virtual memory size of the Linux system, if the memory is less than 1G, when you start the MySQL may produce the following error message:
Starting mysqld (via Systemctl): Job for Mysqld.service failed because the control process exited with error code.
See "Systemctl Status Mysqld.service" and "Journalctl-xe" for details. [FAILED]
如果安装mysql之后,显示mysql isnot running。出错如下:
Starting MySQL..The server quit without updating PID file (/usr/local/mysql/var/localhost.localdomain.pid) 是因为内存不足
安装5.6以及以上版本的mysql需要服务器的内存至少在1G以上。
Third, installation MySQL
1. Unzip the installation package tar-zvxf .....
2. add mysql Group and MySQL user
Add MySQL group: groupadd MySQL
Add MySQL User: useradd-r-g MySQL MySQL
Extended:
To see if a MySQL group exists: more/etc/group | grep MySQL
See which group MSYQL belongs to: Groups MySQL
View the list of currently active users: W
3. Check if the Libaio is installed
Rpm-qa | grep Libaio
If not, install the
Version check: Yum Search Libaio
Installation: Yum-y Install Libaio
4. Create a configuration file my.cnf below /etc/, as follows:
[MySQL]
# Set the MySQL client default character set
Default-character-set=utf8
Socket=/var/lib/mysql/mysql.sock
[Mysqld]
Default_authentication_plugin=mysql_native_password
#skip-name-resolve
#设置3306端口
Port = 3306
Socket=/var/lib/mysql/mysql.sock
# set up the MySQL installation directory
basedir=/usr/local/mysql/mysql5.7/
# Set up a storage directory for MySQL database data
datadir=/usr/local/mysql/mysql5.7/data/
# Maximum number of connections allowed
max_connections=200
# The character set used by the service side defaults to the 8-bit encoded latin1 character set
Character-set-server=utf8
# The default storage engine that will be used when creating a new table
Default-storage-engine=innodb
#lower_case_table_name =1
max_allowed_packet=16m
5. Create the Data folder: mkdir./data
6. Modify the current directory owner for the MySQL User: Chown-r mysql:mysql.
7. Create a directory /var/lib/mysql/
8. Modify the current directory owner for MySQL user chown-r mysql:mysql.
9. Initialize the mysqld (note that the following command must be on the same line and--defaults-file must be in front)
./bin/mysqld--defaults-file=/etc/my.cnf--initialize--user=mysql--basedir=/usr/local/mysql/mysql5.7--datadir=/ usr/local/mysql/mysql5.7/data/
After successful execution, a temporary password is generated and must be remembered.
Iv. Configuration MySQL
4.1 Set boot up
A. Copy the startup script to the resource directory:
CP./support-files/mysql.server/etc/rc.d/init.d/mysqld
B. Add mysqld Service Control script execution permissions:
chmod +x/etc/rc.d/init.d/mysqld
C. Add the MYSQLD service to the system service:
Chkconfig--add mysqld
D. Check if the MYSQLD service is in effect:
Chkconfig--list mysqld
The command output resembles the following result:
Mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Indicates that the MYSQLD service is in effect and starts automatically with the system boot at the 2, 3, 4, 5 runlevel, and can be used to control the start and stop of MySQL later using the service command.
View Startup items: Chkconfig--list | Grep-i MySQL
Delete Startup item: Chkconfig--del MySQL
E. start mysqld: Service mysqld start
4.2 environment variable Configuration
Add the MySQL bin directory to the PATH environment variable and edit the/etc/profile file: Vim/etc/profile
1 2 |
PATH = $PATH:/usr/local/mysql/mysql5.7/bin
export PATH
|
Execute the command to make it effective: source/etc/profile
View the PATH value with the Export command: Echo $PATH
Five, login MySQL
5.1 Test Login
Login mysql:mysql-uroot-p (the temporary password displayed when the login password is initialized)
Initial login requires a password to be set for subsequent database operations: Set PASSWORD = PASSWORD (' 123456 '); (password set to 123456)
Modify the password for password:update user set Authentication_string=password (' Password ') where user= ' root ';
5.2 Firewall Port-couple settings for easy remote access
[Email protected] ~]$ firewall-cmd--zone=public--add-port=3306/tcp--permanent
[Email protected] ~]$ Firewall-cmd--reload
turn on the firewall mysql3306 external access to ports
After upgrading to 7, CentOS replaced the original iptables with Firewalld. Below is a note on how to open Linux ports using FIREWALLD
--zone: Scope, the network region defines the trusted level of the network connection.
This is a one-to-many relationship, which means that a connection can only be part of a region, and a region can be used for many connections
--add-port: Add port and communication protocol in the format: Port/Communication Protocol, protocol TCP or UDP
--permanent: Permanent, without this parameter the port access fails after the system restarts
5.3 Use graphical interface Tools, remote connection, a connection not allowed issue occurred:
First dos Windows ping Linux, troubleshoot network connectivity issues, and then use the graphical interface tool to test it.
Workaround: Login to linux mysql add user account in User Management table
Mysql> Use MSYQL
mysql> create user ' user-name ' @ ' ip-address ' identified by ' password '; (red marked as a place to be modified)
Other options:
To authorize the root user to connect remotely, note replacing the "password" in the following code as the root user's true password,
Also note that if your root user is setting a weak password, it is highly recommended that you do so! :
1 2 |
mysql> grant all privileges on*.* to root@"%" identified by "password"with grant option;
mysql> flush privileges;
|
Linux system offline install MySQL version glibc