1. Download
Here I created a directory software to store the mysql package we will download later, go to this directory first
Command: cd /software
Command: wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar
After the download is complete, you will see files with empty color boxes in the software directory.
Second, create a user, and the mysql directory
1. groupadd mysql #Create a mysql group
2. useradd -r -g mysql mysql #Create a mysql user and put the user in the mysql group
3. passwd mysql #Set a password for the mysql user
Three, decompress mysql
1. Move the tar package to
mv /software/mysql-5.7.17-linux-glibc2.5-x86_64.tar /usr/local in the /usr/local directory
2. Unzip
cd /usr/local
tar xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
[Add directory mysql-5.7.17-linux-glibc2.5-x86_64]
Note: There is no data directory, my.ini is in the support-files directory
3. Change the directory name to /usr/local/mysql (the default installation directory for mysql under linux)
mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
Fourth, configure the relevant startup configuration files ( my-default.cnf and mysql.server files are under /usr/local/mysql/support-files )
1. Copy my-default.cnf to /etc/my.cnf (automatically read when mysqld starts)
cp my-default.cnf /etc/my.cnf
2. Copy mysql.server to the /etc/init.d/ directory [the purpose is to realize the automatic execution effect of mysqld -install at startup]
[/etc/init.d/ directory, equivalent to the registry HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\ services record those services]
cp mysql.server /etc/init.d/mysql (mysql is the service name)
3. Modify the /etc/init.d/mysql parameter
vi /etc/init.d/mysql
to give 2 directory locations
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
4. Change the owner to the directory /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/
5. Solve the garbled problem
vi /etc/my.cnf
[mysql]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character_set_server=utf8
5. Initialize the mysql database
mysql_install_db (the old version)
new version:
1. Initialize
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
A data directory is generated, which means that the database has been successfully initialized and the root user of
mysql generates a temporary password: 5!uipdk>qmg? (generated)
2. Encrypt the database
bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
3. Start mysql
bin/mysqld_safe --user=mysql &
【Check ps -ef|grep mysql】
PS: Here I thought that mysql had been started, but it was not. I also needed /etc/init.d/mysql start to start again:
6. Enter the client
1. Login ./mysql -uroot -p
If the error message is:
Workaround: Deleted the /tmp/mysql.sock.lock file
Command: rm -f /tmp/mysql.sock.lock
2. Modify the password
set password=password('123456');
7. Remote access (that is, you can access mysql of Linux system using Windows system)
Let's first look at the data structure:
Now our Windows system cannot access the mysql of the Linux system under the virtual machine because there is no permission
1. Authorize
grant all privileges on *.* to root@'%' identified by '123456';
select host, user from user; [one more remote login user record]
flush privileges;
Now I use the Windows system to access the mysql of my Linux system, you will find that it is still inaccessible, that is because the firewall is not closed
Command: mysql -h (ip address of your Linux system) -uroot -p123456
2. Turn off the firewall or open the port to the firewall
systemctl stop firewalld.service
The renderings after successful access are as follows:
Eight, set the boot to start automatically
1. Add service mysql
chkconfig --add mysql [mysqld -install]
2. Set mysql service to automatic
chkconfig mysql on
3. Restart check
init 6
ps -ef|grep mysql
Nine, set the path
vi /etc/profile
export PATH=$JAVA_HOME/bin:/usr/local/mysql/bin:$PATH
Reference blog: https://www.cnblogs.com/zczc1996/p/6270521.html
Copyright statement: This article is a blogger reprocessing blog posts under the articles of other bloggers. Please indicate the source for reprinting, thank you!
Here I created a directory software to store the mysql package we will download later, go to this directory first
Command: cd /software
Command: wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar
After the download is complete, you will see files with empty color boxes in the software directory.
Second, create a user, and the mysql directory
1. groupadd mysql #Create a mysql group
2. useradd -r -g mysql mysql #Create a mysql user and put the user in the mysql group
3. passwd mysql #Set a password for the mysql user
Three, decompress mysql
1. Move the tar package to
mv /software/mysql-5.7.17-linux-glibc2.5-x86_64.tar /usr/local in the /usr/local directory
2. Unzip
cd /usr/local
tar xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
[Add directory mysql-5.7.17-linux-glibc2.5-x86_64]
Note: There is no data directory, my.ini is in the support-files directory
3. Change the directory name to /usr/local/mysql (the default installation directory for mysql under linux)
mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
Fourth, configure the relevant startup configuration files ( my-default.cnf and mysql.server files are under /usr/local/mysql/support-files )
1. Copy my-default.cnf to /etc/my.cnf (automatically read when mysqld starts)
cp my-default.cnf /etc/my.cnf
2. Copy mysql.server to the /etc/init.d/ directory [the purpose is to realize the automatic execution effect of mysqld -install at startup]
[/etc/init.d/ directory, equivalent to the registry HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\ services record those services]
cp mysql.server /etc/init.d/mysql (mysql is the service name)
3. Modify the /etc/init.d/mysql parameter
vi /etc/init.d/mysql
to give 2 directory locations
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
4. Change the owner to the directory /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/
5. Solve the garbled problem
vi /etc/my.cnf
[mysql]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character_set_server=utf8
5. Initialize the mysql database
mysql_install_db (the old version)
new version:
1. Initialize
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
A data directory is generated, which means that the database has been successfully initialized and the root user of
mysql generates a temporary password: 5!uipdk>qmg? (generated)
2. Encrypt the database
bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
3. Start mysql
bin/mysqld_safe --user=mysql &
【Check ps -ef|grep mysql】
PS: Here I thought that mysql had been started, but it was not. I also needed /etc/init.d/mysql start to start again:
6. Enter the client
1. Login ./mysql -uroot -p
If the error message is:
Workaround: Deleted the /tmp/mysql.sock.lock file
Command: rm -f /tmp/mysql.sock.lock
2. Modify the password
set password=password('123456');
7. Remote access (that is, you can access mysql of Linux system using Windows system)
Let's first look at the data structure:
Now our Windows system cannot access the mysql of the Linux system under the virtual machine because there is no permission
1. Authorize
grant all privileges on *.* to root@'%' identified by '123456';
select host, user from user; [one more remote login user record]
flush privileges;
Now I use the Windows system to access the mysql of my Linux system, you will find that it is still inaccessible, that is because the firewall is not closed
Command: mysql -h (ip address of your Linux system) -uroot -p123456
2. Turn off the firewall or open the port to the firewall
systemctl stop firewalld.service
The renderings after successful access are as follows:
Eight, set the boot to start automatically
1. Add service mysql
chkconfig --add mysql [mysqld -install]
2. Set mysql service to automatic
chkconfig mysql on
3. Restart check
init 6
ps -ef|grep mysql
Nine, set the path
vi /etc/profile
export PATH=$JAVA_HOME/bin:/usr/local/mysql/bin:$PATH
Reference blog: https://www.cnblogs.com/zczc1996/p/6270521.html
Copyright statement: This article is a blogger reprocessing blog posts under the articles of other bloggers. Please indicate the source for reprinting, thank you!