- 1. Installation and initialization of Mysql database
1.1 Mysql installation
Install MySQL:
$ cd/usr/local/
Query out the installed MARIADB
$ rpm-qa|grep mariadb
$ rpm-e--nodeps file name
$ rm/etc/my.cnf
Execute the following command to create a MySQL user group
$ groupadd MySQL
Execute the following command to create a user named MySQL and join the MySQL user group
$ useradd-g MySQL MySQL
$ mkdir/usr/local/mysql
$ mkdir/usr/local/mysqldata
$ TAR-XVF mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
$ mv mysql-5.7.21-linux-glibc2.12-x86_64. /mysql
If MY.CNF does not exist, it is created and the following configuration is pasted into the configuration file.
$ vi/etc/my.cnf
Parameter description:
[MySQL]
# Set the MySQL client default character set
Default-character-set=utf8
Socket=/usr/local/mysql/mysql.sock
[Mysqld]
Skip-name-resolve
#设置3306端口
port=3306
Socket=/usr/local/mysql/mysql.sock
# set up the MySQL installation directory
Basedir=/usr/local/mysql
# Set up a storage directory for MySQL database data
Datadir=/usr/local/mysqldata
#日志
log=/usr/Local/mysql/log/mysql.log
# 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
# table names are case insensitive
Lower_case_table_names=1
Please read "Security" sections of the manual to find out how to run mysqld as root! error resolution 6725582 |
Empowerment:
cd/usr/local/
Chown-r Mysql:mysql/usr/local/mysql
Chown-r Mysql:mysql/usr/local/mysqldata
Chown 777/etc/my.cnf
Go to install MySQL software catalog
Cd/usr/local/mysql
Yum-y Install numactl.x86_64
./bin/mysqld--initialize--user=mysql
A random password is generated to record.
Set the boot-up service control script
CP Mysql/support-files/mysql.server/etc/rc.d/init.d/mysqld
Increase MYSQLD Service control script execution permissions
chmod +x/etc/rc.d/init.d/mysqld
Adding MYSQLD services to System services
Chkconfig--add mysqld
Check if the Mysqld service is already in effect
Chkconfig--list mysqld
Add Environment variables
VI ~/.bash_profile
Vim/etc/profile
Add Export path= $PATH:/usr/local/mysql/bin
SOURCE ~/.bash_profile
Source/etc/profile
Start MySQL
Systemctl Start mysqld
$ service Mysqld Start
Check MySQL Run line status
Systemctl Status Mysqld
$ Service Mysqld Stop
The following status indicates that MySQL has been started
[[Email protected] ~]# service mysqld stop [[Email protected] ~]# service mysqld start Starting MySQL. success! |
To view the default password:
$ grep ' temporary password '/usr/local/mysql/mysqld.log
To modify the database password:
Log into the database
-uroot
-p+ Auto-generated password
Set a new password
$ set
for
' root ' ' @
localhost ' =password(
mynewpass4! '
= = = External Client Access
Configure IP address; add 3306 port
[Email protected] bin]# Vim/etc/sysconfig/iptables 1 # Firewall configuration written by System-config-firewall 2 # Manual Customization of this file are not recommended. 3 *filter 4:input ACCEPT [0:0] 5:forward ACCEPT [0:0] 6:output ACCEPT [0:0] 7-a input-m State--state established,related-j ACCEPT 8-a input-p icmp-j ACCEPT 9-a input-i lo-j ACCEPT 10-a input-m State--state new-m tcp-p TCP--dport 22-j ACCEPT 11-a input-m State--state new-m tcp-p TCP--dport 21-j ACCEPT 12 13-a input-m State--state new-m tcp-p TCP--dport 3333-j ACCEPT 14-a input-m State--state new-m tcp-p TCP--dport 3306-j ACCEPT 15 # Redis Port. 17-a input-m State--state new-m tcp-p TCP--dport 6379-j ACCEPT 18-a input-m State--state new-m tcp-p TCP--dport 6380-j ACCEPT 19-a input-m State--state new-m tcp-p TCP--dport 6381-j ACCEPT 20 # Redis cluster. 22-a input-m State--state new-m tcp-p TCP--dport 8081-j ACCEPT 23-a input-m State--state new-m tcp-p TCP--dport 8082-j ACCEPT 24-a input-m State--state new-m tcp-p TCP--dport 8083-j ACCEPT 25-a input-m State--state new-m tcp-p TCP--dport 8084-j ACCEPT 26-a input-m State--state new-m tcp-p TCP--dport 8085-j ACCEPT 27-a input-m State--state new-m tcp-p TCP--dport 8086-j ACCEPT 28 29-a input-j REJECT--reject-with icmp-host-prohibited 30-a forward-j REJECT--reject-with icmp-host-prohibited COMMIT 32 |
2. Authorized User access rights
77854690 -Of course, if you want to give permissions to all IPs, then: Grant all privileges on * * to ' root ' @ '% ' identified by ' 123456 '; -Make authorization effective immediately flush privileges;
|
Install MySQL under Linux